Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bernardomennndes/serverless-certification-generator

Node.js Serverless API | Course Certification Generator and Validator
https://github.com/bernardomennndes/serverless-certification-generator

aws dayjs dynamodb handlebars nodejs serverless typescript

Last synced: 20 days ago
JSON representation

Node.js Serverless API | Course Certification Generator and Validator

Awesome Lists containing this project

README

        

Node.js Serverless API - Course Certification Generator and Validator

This project was developed with the goal of structuring an API that could generate a course completion certification with a given student name and grade.

It has an additional functionality of checking if the id of the certification is valid.



Libraries Used

#### Core Libraries

- [Serverless](https://www.serverless.com/)
- [Node.js](https://nodejs.org/en/)
- [AWS](https://aws.amazon.com/pt/sdk-for-javascript/)
- [DynamoDB](https://aws.amazon.com/pt/dynamodb/)

#### Utility Libraries

- [Typescript](https://www.typescriptlang.org/)
- [Handlebars](https://handlebarsjs.com/)
- [Day.js](https://day.js.org)



Installation Instructions

Depending on your preferred package manager, follow the instructions below to deploy your project.

### Using NPM

- Run `npm i` to install the project dependencies

### Using Yarn

- Run `yarn` to install the project dependencies



Deployment Instructions

### Local Deploy

> **Requirement**: NodeJS `lts/fermium (v.14.15.0)`. If you're using [nvm](https://github.com/nvm-sh/nvm), run `nvm use` to ensure you're using the same Node version in local and in your lambda's runtime.

> **Requirement**: Set the environment variables `AWS_BUCKET_NAME` and `AWS_BUCKET_URL` in the `.env` file and in the Lambda section.

- Run `yarn dynamodb:install`, `nmp run dynamodb:install` or `serverless dynamodb install` to install the dynamodb offline database in your local machine.

- Run `yarn dynamodb:start`, `nmp run dynamodb:start` or `serverless dynamodb start` to start the dynamodb offline database in your local machine.

- Run `yarn dev` or `npm run dev` to start the offline application locally.


### AWS Deploy

> **Requirement**: Set your AWS configuration keys by running `serverless config credentials --provider aws --key= --secret=` on your folder terminal by replacing the `` and `` variables with the respective key values of your IAM user.

> **Requirement**: Set the environment variables `AWS_BUCKET_NAME` and `AWS_BUCKET_URL` in the `.env` file and in the Lambda section. Read [this](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-config) article to learn how to configure your environment variables at AWS.

- Run `serverless deploy` to deploy your application to the AWS lambda service.



Endpoints Available

- `[POST] /dev/generateCertification` - Generates the certification.
- `[GET] /dev/validateCertification/{id}` - Validates the certification.



Project structure

The project code base is mainly located within the `src` folder. This folder is divided in:

- `functions` - containing code base and configuration for the lambda functions
- `templates` - containing the certification template
- `utils` - containing shared utility functions and configuration

```
.
├── src
│ ├── functions # Lambda configuration and source code folder
│ │ ├── generateCertification.ts # `generateCertification` lambda source code
│ │ └── verifyCertification.ts # `verifyCertification` lambda source code
│ │
│ ├── utils # Utility folder
│ │ └── dynamodbClient.ts # Database client manager
│ │
| └── templates
│ └── certification.hbs # Certification card template
| └── selo.png # Certification stamp/seal
|
├── package.json
├── serverless.ts # Serverless service file
└── tsconfig.json # Typescript compiler configuration
```



Certification Preview