Users micro-service for ToDo App ❤️
Clone the repo
git clone https://github.com/princeahugah/UserService.git
Install sequelize cli and typescript
yarn global add sequelize-cli typescript
Install node modules
yarn install
Setup environment variables
port = 3001
NODE_ENV = development
DB_USERNAME = db-user
DB_PASSWORD = pass123
HASHING_ALGORITHM = sha256
AUTH_SECRET = XbSK5mSY2IHiJCKHChhpaObq8YLDUH60nTFkZDHBXNRDBGyQlCViHTaV9
CORS_ORIGIN_WHITELIST = ["http://localhost:3000", "http://95.179.201.200:3000"]
CORS_ALLOWED_HEADERS = ["Content-Type", "Authorization", "Origin", "X-Requested-With", "Accept"]
CORS_EXPOSED_HEADERS = ["x-response-time"]
CORS_METHODS = ["POST", "OPTIONS", "GET", "DELETE", "PUT"]
Setup log directory
sudo mkdir -p /var/apps/log
Run DB migration: We are using sqlite3 as the database. You can check the configuration in migrations/config.json
yarn run migrate
Confirm your tables have been setup properly
sqlite3 dev_database.sqlite3
sqlite> .schema
ctrl + D to exit Note: development and production files are stored in /tmp directory
yarn run dev
Your web server is now exposed on http://localhost:3001
curl -XGET http://localhost:3001/api/users
curl -XGET http://localhost:3001/api/users/24ce245e-8159-491f-8dc9-24c6d190baba
curl -XPOST -H 'Content-Type: application/json' -d '{"name":"Prince"}' http://localhost:3001/api/users
curl -XPUT -H 'Content-Type: application/json' -d '{"name":"Ahugah"}' http://localhost:3001/api/users/24ce245e-8159-491f-8dc9-24c6d190baba
curl -X DELETE http://localhost:3001/api/users/24ce245e-8159-491f-8dc9-24c6d190baba
Mocha tests
yarn run test
Within this repo is a Jenkinsfile with defines how this project should be built and deployed. See a screenshot of a jenkins build job below. It logs the status of the build to a slack channel.