API to serve data over RESTful calls for a user tracking software. The server uses lokijs, a in-memory JavaScript Datastore with Persistence.
npm install
npm run dev
Firstly, To create users :
POST localhost:4999/signup
{
"email": "[email protected]",
"password": "test",
"phone": "444-333-1111"
}
Login (generate events):
POST localhost:4999/login
{
"email": "[email protected]",
"password": "test"
}
Response:
{
"message": "Created user with email [email protected]"
}
- Return all events for all users:
GET localhost:4999/events/all
Response:
[
{
"type": "LOGIN",
"created": 1542333383634,
"user": "[email protected]"
},
{
"type": "LOGIN",
"created": 1542333385639,
"user": "[email protected]"
},
{
"type": "LOGIN",
"created": 1542333386152,
"user": "[email protected]"
},
{
"type": "LOGIN",
"created": 1542333431608,
"user": "[email protected]"
}
]
- Return all events for a single user
GET localhost:4999/events/user?[email protected]
Response:
Response:
[
{
"type": "LOGIN",
"created": 1542333903026,
"user": "[email protected]"
}
]
- Return all events for the last day
GET localhost:4999/events/lastday
Response:
[
{
"type": "LOGIN",
"created": 1542333903026,
"user": "[email protected]"
},
{
"type": "LOGIN",
"created": 1542333907333,
"user": "[email protected]"
},
{
"type": "LOGIN",
"created": 1542333908067,
"user": "[email protected]"
}
]
- Integrate https://jwt.io/ to authorize/authenticate properly
- Use a persistent database
- Create test cases
- Refactor repetitive code specially in the endpoints logic
- Add ssl for https before deploying on a production server