A simple check-in server built using the MEN (MongoDB, Express, Node.js) stack, with functionality for user registration, login, check-in, and check-out.
- User registration and login with JSON Web Token (JWT) authentication
- Check-in and check-out functionality, with timestamps stored for each event
- Secure password hashing using bcrypt
- Clone the repository:
git clone https://github.com/Code-Gale/checkIn-server.git
- Navigate to the project directory:
cd checkin-server
Copy
- Install the dependencies:
npm install
- Set up the environment variables:
Create a .env
file in the project root and add the following variables:
DBURI = mongodb://localhost/checkin-server SECRET_KEY= your_secret_key PORT = 5000
Replace your_secret_key
with a secret key of your choice.
- Start the server:
npm start
The server will start running on http://localhost:5000
.
- Registration:
- Endpoint:
POST /api/v1/register
- Request body:
{ "username", "email", "password" }
- Response:
{ "token" }
- Login:
- Endpoint:
POST /api/v1/login
- Request body:
{ "email", "password" }
- Response:
{ "token" }
- Check-in:
- Endpoint:
POST /api/v1/checkin
- Headers:
Authorization: Bearer <token>
- Response:
{ "message": "Checked in successfully" }
- Check-out:
- Endpoint:
POST /api/v1/checkout
- Headers:
Authorization: Bearer <token>
- Response:
{ "message": "Checked out successfully" }
- MongoDB: NoSQL database for storing user and check-in/check-out data
- Express: Web application framework for Node.js
- Node.js: JavaScript runtime environment
- bcrypt: Library for hashing passwords
- jsonwebtoken: Library for generating and verifying JSON Web Tokens
If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.