Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mad-coders/jwt-serverless-authentication
https://github.com/mad-coders/jwt-serverless-authentication
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mad-coders/jwt-serverless-authentication
- Owner: mad-coders
- License: mit
- Created: 2019-08-03T12:46:14.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T04:59:07.000Z (almost 2 years ago)
- Last Synced: 2024-11-06T20:09:01.014Z (2 months ago)
- Language: TypeScript
- Size: 2.32 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# angular-auth-api
## Run develop
Requirements:
```
- node
- docker-compose
```Steps:
```
1. npm i
2. npm run db:docker
3. npm run start:dev
```DynamoDB local: http://localhost:8000
API endpoint: http://localhost:3000
Swagger (http://localhost:3001/api):
```
npm run swagger
```## Production
Requirements:- aws-cli (https://docs.aws.amazon.com/cli/latest/userguide/install-bundle.html)
- serverless-cli (https://serverless.com/)
Start production offline: `npm run sls:offline`
Deploy:
```
1. npm i
2. aws configuration
3. edit config file (src/shared/config.index.ts)
4. npm run sls:deploy
```## Add more DB providers, for example MongoDB
### 1. Import MongooseModule into db.module.ts
```javascript
@Module({
...
imports: [
...
MongooseModule.forRoot('mongodb://localhost/madocders'),
...
],
...
})
```### 2. Create mongoose schema
```javascript
export const userSchema = new mongoose.Schema({
username: String,
password: String,
firstName: String,
lastName: String,
organization: String,
});
```### 3. Import UserSchema into db module
```javascript
@Module({
...
imports: [
...
MongooseModule.forRoot('mongodb://localhost/madocders'),
MongooseModule.forFeature([{ name: 'User', schema: UserSchema }])
...
],
...
})
```### 4. Inject UserModel into service
```javascript
@InjectModel('User') private readonly userModel: Model
```## Docs
- NestJS (https://nestjs.com/)- Serverless (https://serverless.com/)
## Process env config
```
JWT_SECRET
AWS_ACCESS_KEY
AWS_ACCESS_SECRET
```