Backend service for the NearTag device management system. This API provides endpoints for user management, device tracking, and location services.
- User authentication with JWT
- Device management and tracking
- Real-time location updates
- Profile management
- Role-based access control
- Swagger documentation
- Node.js
- TypeScript
- Express.js
- Prisma ORM
- PostgreSQL
- JSON Web Tokens
- Zod for validation
- Swagger/OpenAPI
- Node.js (v18 or higher)
- PostgreSQL
- npm or yarn
- Clone the repository:
git clone https://github.com/yourusername/neartag.git
cd neartag- Install dependencies:
npm install- Create a
.envfile in the root directory:
DATABASE_URL="postgresql://user:password@localhost:5432/neartag"
SECRET_KEY="your-secret-key"
PORT=3000- Run database migrations:
npx prisma migrate dev- Start the development server:
npm run devThe API documentation is available through Swagger UI at:
http://localhost:3000/api-docs
POST /register- Create new user accountPOST /login- User authenticationPOST /refresh-token- Refresh access tokenPOST /signOut- User logout
PATCH /users/:userId/username- Update usernamePATCH /users/:userId/email- Update emailPATCH /users/:userId/phone-number- Update phone numberPATCH /users/:userId/password- Update passwordGET /users/:userId- Get user details
POST /assign- Assign device to userPATCH /devices/:deviceId/lost- Mark device as lostGET /users/:userId/devices- Get user's devicesDELETE /devices/:deviceId- Remove deviceGET /devices/:deviceId/location- Get device location
The API uses JWT for authentication. Include the token in the Authorization header:
Authorization: Bearer <your-token>
The API uses standard HTTP status codes and returns consistent error objects:
{
"error": "Error message",
"detail": "Additional error details"
}- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request