An API to manage a user persistence layer
- The API exposes a user model with the following properties: id, email, forename, surname, date created
- The following endpoints are exposed: create, read, update, delete
- Can be consumed using Google Chrome's Postman. See repo for User_API.postman_collection file, which can be imported by Postman
- Input is validated and sanitised with sequalize's build in validation
- Install node version
v6.9.4
- App dependencies -
npm install
- Install PostGres - to allow user data to be persisted the app requires a connection to an instance of PostGres SQL. The local connection string is specified in the config.js file.
- ensure that postgres is running
brew services start postgresql
if on mac os - run
createuser -P user_name
replacinguser_name
with your current user name - run
createdb db_name
replacingdb_name
with your current user name
- To start the Node.js server run
npm start
On startup the app will create a users table and insert some users read fromscripts/baseData.json
to use for storing, reading, writing, and deleting 'user' information
- Unit tests are run with Mocha which can run with
npm run test:coverage
. - Linting is run using StandardJs which can be run with
npm run lint
.
Once the server is running, the api is documented using swagger, which can be accessed by going to http://localhost:3500/