https://github.com/xscriptorcode/api-only-project
https://github.com/xscriptorcode/api-only-project
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/xscriptorcode/api-only-project
- Owner: xscriptorcode
- License: mit
- Created: 2024-11-06T01:27:51.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-06T09:23:33.000Z (about 1 year ago)
- Last Synced: 2025-01-30T15:29:12.479Z (11 months ago)
- Language: TypeScript
- Homepage: https://api-only-project.vercel.app
- Size: 230 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# API-Only Project
This project is an API-only setup built with Next.js and deployed on Vercel. It includes a subscription endpoint (`/api/newsletter`) that handles email subscriptions by receiving and validating email addresses. This project is designed for a standalone API deployment to work in tandem with a frontend hosted on a separate platform (e.g., Hostinger).
## Project Structure
The main components of the project include:
api-only-project/
├── app/
│ └── api/
│ └── newsletter/
│ └── route.ts
├── prisma/
│ └── schema.prisma
├── package.json
├── next.config.js
└── .env.example
- **`app/api/newsletter/route.ts`**: Handles the API endpoint for email subscriptions (`POST /api/newsletter`).
- **`prisma/schema.prisma`**: Defines the Prisma database schema.
- **`.env.example`**: Example environment file listing necessary environment variables.
## Getting Started
### Prerequisites
- **Node.js** and **npm** installed on your system.
- **Git** for version control.
- A **database** compatible with Prisma (e.g., MySQL, PostgreSQL).
### Installation
1. Clone the repository:
```bash
git clone https://github.com/your-username/api-only-project.git
cd api-only-project
2. Install dependencies:
```bash
npm install
3. set up environment variables:
Create a .env file based on .env.example and add your DATABASE_URL and other required variables.
4. Run Prisma migrations and generate the Prisma client:
```bash
npx prisma migrate deploy
npx prisma generate
Start the development server:
**npm** run **dev**
Deployment
This API is designed to be deployed on Vercel. Follow these steps:
Push your code to GitHub.
Connect your GitHub repository to Vercel.
Set up environment variables in Vercel.
Deploy the project and obtain your public URL.
License
This project is licensed under the MIT License - see the LICENSE file for details.