Calendar backend project for written in nodejs. Model works for an ios app.
The project provides CRUD operation for and event (calendar) based on specs. The repository is PostgreSQL. There are Unit tests for all endpoints. All the response are in the format: {success: {boolean}, error: {Object}, data: {Object}} with data having the required information. Comments are in the calendarModel and calendarRepo files.
- There are no validations related to schema structure required for the APIs. If a field required to save an event is not sent it will throw a DB error (not very descriptive). If there is an error it thows a 422 HTTP code.
- Authentication.
-- bin start.js file to start the app (npm start)
-- config configuration files
-- domain For now only index.js used to connect to the DB
-- logger winston logger
-- models models/business logic
-- repository Repo to PostgreSQL
-- routes
-- test
-- scripts Scripts to set up the DB
-- www app.js and www.js files. Set up express server, add middleware and run it.
- Execute scripts provided in /scripts folder. There might be permission issues depending on the user. Commenting this line might help:
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
- Make sure the DB has the timezone set to UTC. If using Amazon RDS use this command:
ALTER USER postgres SET timezone='UTC' ;
or check these links: https://stackoverflow.com/questions/11779293/how-to-set-timezone-for-postgres-psql https://stackoverflow.com/questions/6663765/postgres-default-timezone
- Add new modules based on package.json file if needed.
- Attach middleware. Probably the only module needed is json-inflector. See app.js lines 39-44.
- Add endpoints from the routes.js.
- Add models/calendarModel.js file and repository/calendarRepo.js file. If you have a an existing connection pool to knex change the reference in calendarRepo.js, otherwise also include domain/index.js.
mocha test/calendarTest.js