https://docs.npmjs.com/getting-started/installing-node
https://www.npmjs.com/package/typescript
CREATE TABLE test (
testcolumn VARCHAR(20)
);
download and run npm install
export DB_USER='' DB='' DB_PASS='' DB_HOST='' DB_PORT='' DB_MAX_CLIENTS='' DB_IDLE_TIMEOUT_MS=''
this can also be done by creating a .env
file in the root of this project see .env.example
for a reference
npm start
- Transpile TypeScript to the build folder
run tsc
- Run ESLint
npm run lint
- Run your built node app
node build/app.js
http://localhost:3000/healthcheck and root return healthcheck
http://localhost:3000/servertime - returns servertime
http://localhost:3000/transaction - deletes then inserts into your DB using a transaction
- basic unit test examples have been added using Jest
npm test
-
documentation here
-
use parameterized queries to prevent SQL injection
-
if you want to do more with data types