Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/josueec/user-service-sls-c2c
users serverless microservice for the example c2c platform
https://github.com/josueec/user-service-sls-c2c
Last synced: 6 days ago
JSON representation
users serverless microservice for the example c2c platform
- Host: GitHub
- URL: https://github.com/josueec/user-service-sls-c2c
- Owner: JosueEC
- Created: 2024-05-15T01:37:27.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2024-05-23T02:30:02.000Z (6 months ago)
- Last Synced: 2024-05-23T03:32:05.294Z (6 months ago)
- Language: TypeScript
- Size: 95.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Serverless Framework Node HTTP API on AWS
This template demonstrates how to make a simple HTTP API with Node.js running on AWS Lambda and API Gateway using the Serverless Framework.
This template does not include any kind of persistence (database). For more advanced examples, check out the [serverless/examples repository](https://github.com/serverless/examples/) which includes Typescript, Mongo, DynamoDB and other examples.
## Usage
### Deployment
```
$ serverless deploy
```After deploying, you should see output similar to:
```bash
Deploying aws-node-http-api-project to stage dev (us-east-1)✔ Service deployed to stack aws-node-http-api-project-dev (152s)
endpoint: GET - https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/
functions:
hello: aws-node-http-api-project-dev-hello (1.9 kB)
```_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [http event docs](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/).
### Invocation
After successful deployment, you can call the created application via HTTP:
```bash
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
```Which should result in response similar to the following (removed `input` content for brevity):
```json
{
"message": "Go Serverless v2.0! Your function executed successfully!",
"input": {
...
}
}
```### Local development
You can invoke your function locally by using the following command:
```bash
serverless invoke local --function hello
```Which should result in response similar to the following:
```
{
"statusCode": 200,
"body": "{\n \"message\": \"Go Serverless v3.0! Your function executed successfully!\",\n \"input\": \"\"\n}"
}
```Alternatively, it is also possible to emulate API Gateway and Lambda locally by using `serverless-offline` plugin. In order to do that, execute the following command:
```bash
serverless plugin install -n serverless-offline
```It will add the `serverless-offline` plugin to `devDependencies` in `package.json` file as well as will add it to `plugins` in `serverless.yml`.
After installation, you can start local emulation with:
```
serverless offline
```To learn more about the capabilities of `serverless-offline`, please refer to its [GitHub repository](https://github.com/dherault/serverless-offline).