Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/darrylmorley/node-express-ts-auth
Node.js Express TypeScript Authentication Starter
https://github.com/darrylmorley/node-express-ts-auth
Last synced: about 2 months ago
JSON representation
Node.js Express TypeScript Authentication Starter
- Host: GitHub
- URL: https://github.com/darrylmorley/node-express-ts-auth
- Owner: darrylmorley
- Created: 2023-09-26T13:40:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-23T19:56:26.000Z (about 1 year ago)
- Last Synced: 2023-10-23T20:41:03.454Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node.js Express TypeScript Authentication Starter
This is a starter template for building a Node.js, Express.js, TypeScript web application with user authentication. It uses Mongoose as the database for user management and provides a foundation for building secure and scalable web applications.
## Features
- Node.js and Express.js for the backend server.
- TypeScript for type safety and improved development experience.
- Mongoose for MongoDB integration and user data storage.
- Authentication system with user registration, login, and JWT-based authentication.
- Secure password hashing using bcrypt.
- CORS support for cross-origin requests.
- Compression middleware for optimizing response size.
- Cookie parsing for session management.## Prerequisites
Before you begin, ensure you have met the following requirements:
- Node.js installed on your local machine.
- MongoDB instance (local or remote) and connection string.## Installation
1. Clone this repository:
```bash
git clone https://github.com/darrylmorley/node-express-ts-auth.git
```2. Install the project dependencies:
```bash
cd node-express-ts-auth
npm install
```3. Create a .env file in the project root directory and set the following environment variables:
```bash
PORT=8080
MONGO_DB_STRING=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
```4. Customise and Create!
---
## API Endpoints
- /api/register - User registration endpoint.
- /api/login - User login endpoint.
- /api/logout - User logout endpoint.
- /api/user - Get the current user's profile (requires authentication).---
## Acknowledgments
- [Express.js](https://expressjs.com/): Web framework for Node.js.
- [Mongoose](https://mongoosejs.com/): MongoDB object modeling for Node.js.
- [bcrypt](https://www.npmjs.com/package/bcrypt): Password hashing library.
- [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken): JSON Web Token (JWT) library.---
## Contributing
Contributions are welcome! Feel free to open issues or submit pull requests to improve this starter template.