This project is a backend template for an e-commerce store using Node.js, Express.js, TypeScript, Prisma, and Turso.
- Node.js and Express.js for the server.
- TypeScript for type safety.
- Prisma for database ORM.
- Turso for database management.
- Modular routing for easier management of endpoints.
-
Clone the repository:
git clone https://github.com/your-username/backend-template.git
-
Navigate into the project directory:
cd backend-template
-
Install the dependencies:
npm install
-
Set up environment variables:
- Create a
.env
file in the root directory. - Add your database URL and authentication token:
TURSO_DATABASE_URL=your_database_url TURSO_AUTH_TOKEN=your_auth_token
- Create a
-
Apply Migrations:
npm run tpush
-
Start the Server:
npm start
-
Access the Endpoints:
- Products:
http://localhost:3001/api/products
- Products:
-
migrate
: Run migrations using Prisma.npm run migrate
-
db:update
: Push the Prisma schema to the database.npm run db:update
-
gen
: Generate Prisma client.npm run gen
-
tpush
: Apply migrations to Turso database.npm run tpush
prisma/
: Contains the Prisma schema and migration files.routes/
: Contains route files, such asproduct.get.ts
for product-related routes.scripts/
: Contains scripts, such asmigrate2Turso.js
for migration handling.utils/
: Contains utility files, such as database connection setup.
This project is licensed under the MIT License - see the LICENSE file for details.