Tasks micro-service for ToDo App ❤️
Clone the repo
git clone https://github.com/princeahugah/TaskService.git
Install sequelize cli and typescript
yarn global add sequelize-cli typescript
Install node modules
yarn install
Setup environment variables
port = 3002
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:3002
curl -XGET http://localhost:3002/api/tasks/b2488515-4341-46d8-9548-3f4f6ee03176
curl -XPOST -H 'Content-Type: application/json' -d '{"state":"to do","description":"Learning Node.js","userId":"b2488515-4341-46d8-9548-3f4f6ee03176"}' http://localhost:3002/api/tasks
curl -XPUT -H 'Content-Type: application/json' -d '{"state":"done","userId":"b2488515-4341-46d8-9548-3f4f6ee03176"}' http://localhost:3002/api/tasks/ba0000b0-eb10-4f25-97eb-8cf70e36d2a1
curl -X DELETE http://localhost:3002/api/tasks/ba0000b0-eb10-4f25-97eb-8cf70e36d2a1
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.