- JWT (For Stateless Auth)
- Chai + Mocha (For Testing)
- Redis (For In-Memory DB)
- MongoDB + Mongoose (For Persistent DB)
- Express in TypeScript
To test this,
- Pull Docker Image
$ cd nodets-mongojwt-chai
$ docker pull burningraven06/nodets-jwt-mongo-chai-rds
- Start Mongo Container
$ docker pull mongo
$ docker run --name <MONGO_INSTANCE> -d mongo
- Start Redis Container
$ docker pull redis
$ docker run --name <REDIS_INSTANCE> -d redis
# You may need to update your docker redis.conf
- Start App & Link Containers
$ docker run --name <APP_INSTANCE> --link <MONGO_INSTANCE_NAME>:mongo --link <REDIS_INSTANCE> -p 5000:4000 -d burningraven06/nodets-jwt-mongo-chai-rds
# Visit localhost:5000
- Create DBKeys
$ cd nodets-mongojwt-chai
$ touch src/keys/dbKeys.ts
- Update DBKEys
const dbKeys = {
mongoLocalUrl : <YOUR_MONGODB_URI>,
mongoDockerURL : ""
}
export default dbKeys
- Create JWTSecrets
$ cd nodets-mongojwt-chai
$ touch src/keys/jwtSecret.ts
- Update JWTSecrets
const jwtKeys = {
tokenSecret : <YOUR_TOKEN_SECRET>,
resfreshTokenSecret : <YOUR_REFRESHTOKEN_SECRET>
}
export default jwtKeys
- Update src/app.ts
$ cd nodets-mongojwt-chai/src/ #Open app.ts
#Change Line 25
mongoDBConfig.dockerSetup()
# to
mongoDBConfig.localSetup()
- Update src/controllers/user/authenticate.ts
$ cd nodets-mongojwt-chai/src/controllers/user/ #Open authenticate.ts
#Change Line 9
var redisDB = redis.createClient(6379, "redis")
# to
var redisDB = redis.createClient(6379, "localhost")
- Update src/controllers/user/refreshToken.ts
$ cd nodets-mongojwt-chai/src/controllers/user/ #Open refreshToken.ts
#Change Line 7
var redisDB = redis.createClient(6379, "redis")
# to
var redisDB = redis.createClient(6379, "localhost")
$ cd nodets-mongojwt-chai
$ yarn install
# or with npm
$ npm install
$ cd nodets-mongojwt-chai
$ yarn run watch-test-ts
$ cd nodets-mongojwt-chai
$ yarn run watch-ts
$ yarn run watch-js
$ cd nodets-mongojwt-chai
$ yarn start