General costumer handling with Express. Server side for react-costumer SPA.
- Language - JavaScript/NodeJS, Express, bcrypt, Mongojs/MongoDB
The application isserver side for React app dpetrini/react-costumer The source files are divided in folders inside js/source directory as follows:
- config: files to hold environment variables like which mogo db server to use
- controllers: the C of MVC, holds the logic to interface react client app to database
- db: holds the connection to mongo db
- middleware: custom express middleware
- models: M of MVC, holds real connection to db and other server related functions.
- public: file that holds the react client app when in production
- routes: express routes for this app
- tests: unit and api tests, mocha based (not complete yet)
- views: temporaty pug views for data handling in server
Login entry point.
Body Param | Description |
---|---|
User email as ID | |
password | User password |
Logout entry point.
HTTP | Value |
---|---|
Body | { "OK"} |
Create costumer entry in database.
Body Param | Description |
---|---|
firstName | First name |
lastName | Last name |
contactNumber | Phone number |
Email address |
HTTP | Value |
---|---|
Body | { "_id", "firstName", "lastName", "contactNumber", "email"} |
Sends all costumers content.
HTTP | Value |
---|---|
Body | { "_id", "firstName", "lastName", "contactNumber", "email"} |
Before testing or running the service should be properly configured with following environment variables.
Key | Value | Description |
---|---|---|
process.env.NODE_ENV | production or development or test |
Defines the API entry points for testing or production. |
MONGODB_USER | mongo user |
user to run the database. |
MONGODB_PASSWD | mongo password |
passoword for user to run the database. |
DEBUG | users:* |
Use to enable debug messages. |
Obs. For tests please set up local mongo db and user blank values for the above.
Mocha, instanbul, converage
To run:
npm test-api
npm test-html
(not complete yet)
Download this repository. And export the above environment variables, then make sure to open react app.
Using npm:
$ npm install
$ npm start
Open in your browser
http://localhost:3000
- Clean pug temporary templates
- Create support for proposals database, and other missing CRUD operations for current ones