A RESTful API server for a note-taking application, built with Node.js, TypeScript, and Express. Supports user authentication (including Google OAuth), note management, and user profile features. Designed to work seamlessly with the React App Notes frontend.
- User authentication (username/email & password, Google OAuth)
- Create, edit, and delete notes
- User profile management (update name, username, password)
- Per-user memory usage tracking and limits
- Secure password hashing with bcrypt
- JWT-based authentication and authorization
- Error handling and validation
- CORS support for frontend integration
- Backend: Node.js, TypeScript, Express
- Database: MySQL (via mysql2)
- Authentication: JWT, bcrypt, Google OAuth
- Environment: dotenv for configuration
- Environment Variables:
- Copy
.env.exampleto.envand fill in your database, JWT, and OAuth credentials. - See [https://console.cloud.google.com/apis/credentials] and create your own credentials.
- Make sure your MySQL server is running and accessible from your backend.
- Copy
- Frontend:
- Designed to work with Notes React App.
- Set
FRONTEND_APP_URLto your frontend's URL.
-
Clone the repository:
git clone https://github.com/Shan0102/Notes-Server.git cd Notes-Server -
Install dependencies:
npm install
-
Set up environment variables:
- Copy
.env.exampleto.envand edit as needed.
- Copy
-
Build the project:
npm run build
-
Start the server:
npm start
POST /api/users— Register a new userPOST /api/users/login— Login with username/email and passwordPUT /api/users/info/:user_id— Update user info (auth required)PUT /api/users/password/:user_id— Change password (auth required)DELETE /api/users/:user_id— Delete user (auth required)POST /api/notes— Create a note (auth required)GET /api/notes/user/:user_id— Get all notes for a user (auth required)GET /api/notes/:note_id— Get a note by ID (auth required)PUT /api/notes/:note_id— Update a note (auth required)DELETE /api/notes/:note_id— Delete a note (auth required)GET /api/sessions/oauth/google— Google OAuth login
- Connect your frontend app to the API server at the configured URL.
- Use the provided endpoints for user and note management.
- Authenticate requests using JWT tokens returned on login or OAuth.
This project is licensed under the MIT License.
For questions or feedback, please contact [shandev01@proton.me].