-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from getlift/add-type-generation
Add types definition for serverless.ts
- Loading branch information
Showing
4 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Lift Typescript definitions | ||
|
||
While YAML remains the most popular declarative syntax for Serverless service file definition - a.k.a `serverless.yml` - you can also use Javascript/Typescript definitions - i.e. `serverless.js` and `serverless.ts`. You can find more information on using JS/TS service file in the [Serverless official documentation](https://www.serverless.com/framework/docs/providers/aws/guide/intro#services). | ||
|
||
Generated Typescript types for the service file from [@serverless/typescript](https://github.com/serverless/typescript) do NOT include `constructs` definition from Lift. | ||
|
||
In order to cope this issue, Lift exports a type definition you can use in conjonction with the official Serverless definition: | ||
|
||
_serverless.ts_ | ||
```ts | ||
import type { AWS } from '@serverless/typescript'; | ||
import type { Lift } from "serverless-lift"; | ||
|
||
const serverlessConfiguration: AWS & Lift = { | ||
service: 'myService', | ||
frameworkVersion: '2', | ||
plugins: ['serverless-lift'], | ||
constructs: { | ||
avatars: { | ||
type: 'storage', | ||
}, | ||
}, | ||
provider: { | ||
name: 'aws', | ||
runtime: 'nodejs14.x', | ||
}, | ||
functions: { | ||
hello: { | ||
handler: 'src/publisher.handler', | ||
} | ||
} | ||
}; | ||
|
||
module.exports = serverlessConfiguration; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters