Don't Know? CheckFirst. A tool to build eligibility checkers and calculators for Singapore Government policies
git clone [email protected]:opengovsg/checkfirst
cd checkfirst
npm ci
npm run dev
As defined in src/server/config
src/server/index.tsfor Express.jssrc/server/serverless/{api, static}.tsfor deployments into API Gateway + AWS Lambda
api/- API routing to authentication, CRUD operationsauth/- Authentication layerbootstrap/- Factory function to build the Express.js application for the backendchecker/- CRUD operations layer to manage checkers created by the usermodels/- Sequelize modelsutils/- miscellaneous functions
src/client/index.tsx- mountssrc/client/App.tsxonto document
By default SQLite DB is used. For other available environments refer to: src/server/database/config/config.ts or edit the dialect for development environment to postgres
This may occur if the SQlite tables created is in the wrong format or required tables are not created
Add await sequelize.sync({ force:true }) to the src/server/bootstrap/index file after await sequelize.authenticate(). This will force all the tables in to be dropped and created again with the correct tables.
A potential long term fix for issues related to SQLite is to replace SQLite with a docker-compose environment for usage during development.
This section explains the steps required to perform remote database schema migrations using a bastion SSH instance.
- Ensure that your current IP address has been whitelisted in the bastion instance security group on AWS
- Set up a local port-forwarding service by running the following in a terminal window:
ssh -L 5433:<DB_HOST>:5432 <SSH_TUNNEL_USER>@<SSH_TUNNEL_HOST> -i <PATH_TO_SSH_HOST_PEM_FILE> - Set your
NODE_ENVenvironment variable to eitherstagingorproduction - Set your
DATABASE_URLenvironment variable to the followingpostgres://<DB_USER>:<DB_PASS>@127.0.0.1:5433/<DB_NAME> - Ensure that the env vars are loaded correctly
- Perform the up-migration by running the following in another terminal window:
npx sequelize db:migrate; perform the down-migration by runningnpx sequelize db:migrate:undo - Verify that your migrations were completed correctly by checking that the name of the migration exists in the
SequelizeMetatable in the database