This service aims to manage authentication and users.
The service is built on the top of ExpressJS and Sequelize is used as ORM. While PostgreSQL is used as prod database, SQLite is preferred as test database.
Babel 7 is used to convert ECMAScript 2015+ code and Node target version is 14.
In the test side, Jest is used as the testing framework.
Currently, only the database config is determined by this parameter. It takes the following values.
- production
- development
- test
config.js
export const configs = {
development: {
uri: process.env?.DEV_DB_URI ?? 'postgres://postgres:password@localhost:5432/dev_service_auth',
logging: true
},
test: {
uri: process.env?.TEST_DB_URI ?? 'sqlite::memory:',
logging: false
},
production: {
uri: process.env?.PROD_DB_URI ?? 'postgres://postgres:password@localhost:5432/service_auth',
logging: false
}
}
These variables take database URI like followings.
postgres://postgres:password@db:5432/service_auth
sqlite::memory:
More samples: https://sequelize.org/master/manual/getting-started.html
This is the secret key for JWT, keep it safe!
Runs all tests using Jest.
npm run test
Extracts a Node 14 compatible build folder using Babel.
npm run build
Starts a server from /dist folder.
npm run server
- tests
- src
- db
- config
# Holds database profiles and connection object.
- models
# Holds Sequelize models.
- enums
- exceptions
- middlewares
# Middlewares like authHandler are held here.
- services
# Database related business logics are managed under this folder.
- utils
- index.js
- routes.js
- server.js