Change or add env variables
Example
DATABASE_CLIENT_DEV="pg"
DATABASE_HOST_DEV="your-group-postgresql-instance-primary-dev.abcdef.us-east-1.rds.amazonaws.com" # your database host
DATABASE_PORT_DEV=5432 # postgres port
DATABASE_DATABASE_DEV="cmpappdb1" # database name
DATABASE_USER_DEV="lambdacmprdsrw" # username
DATABASE_SCHEMA_DEV="bmme_metric_repo" # schema
Update with the variables knexfile.ts
.
import dotenv from 'dotenv';
dotenv.config();
// Update with your config settings.
module.exports = {
bmmeMetricRepoDatabase: { // this key can be change but need to change for both [db-injector.ts](./src/db/db-injector.ts:68)
client: process.env.DATABASE_CLIENT_DEV,
connection: {
host: process.env.DATABASE_HOST_DEV,
port: process.env.DATABASE_PORT_DEV,
database: process.env.DATABASE_DATABASE_DEV,
user: process.env.DATABASE_USER_DEV,
// password: '', this project use aws token instead of password.
},
searchPath: [process.env.DATABASE_SCHEMA_DEV],
debug: true,
// ssl: process.env.DATABASE_SSL === 'true',
// debug: process.env.DATABASE_DEBUG_DEV === 'true',
pool: {
min: 0,
max: 6,
idleTimeoutMillis: 10000
},
},
};
Update with the variables knexfile.ts
.
import dotenv from 'dotenv';
dotenv.config();
// Update with your config settings.
module.exports = {
development: {
client: 'pg',
connection: {
host: 'db_host',
port: 'db_port',
database: 'db_name,
user: 'db_username,
},
searchPath: [process.env.DATABASE_SCHEMA_DEV],
debug: true,
// ssl: process.env.DATABASE_SSL === 'true',
// debug: process.env.DATABASE_DEBUG_DEV === 'true',
pool: {
min: 0,
max: 6,
idleTimeoutMillis: 10000
},
},
test: {
client: 'pg',
connection: {
host: 'db_host',
port: 'db_port',
database: 'db_name,
user: 'db_username,
},
searchPath: [process.env.DATABASE_SCHEMA_DEV],
debug: true,
// ssl: process.env.DATABASE_SSL === 'true',
// debug: process.env.DATABASE_DEBUG_DEV === 'true',
pool: {
min: 0,
max: 6,
idleTimeoutMillis: 10000
},
},
production: {
client: 'pg',
connection: {
host: 'db_host',
port: 'db_port',
database: 'db_name,
user: 'db_username,
},
searchPath: [process.env.DATABASE_SCHEMA_DEV],
debug: true,
// ssl: process.env.DATABASE_SSL === 'true',
// debug: process.env.DATABASE_DEBUG_DEV === 'true',
pool: {
min: 0,
max: 6,
idleTimeoutMillis: 10000
},
},
};
You should update the line 68 of db-injector.ts
configByEnvironment = dbConfig[process.env.NODE_ENV];
$ npm i -g @nestjs/cli # instlal nestjs cli
$ npm install # install dependencies
- Docker must be up and running
- pgAdmin must be set up with a database, username and password
docker-compose up
- aws saml must be logined
# creating an API resource(controller, modue, service) at one go with basic CRUD entry points
$ nest generate resource [name]
# module
$ nest g mo [apiName]
# service
$ nest g s [apiName]
# controller
$ nest g co [apiName]
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
- You will need to run API builder job to apply changes to aws server.