This project sets up an Express server with GraphQL integration and cron jobs for periodic tasks. It utilizes Node.js, Express.js, GraphQL, and Cron.
- GraphQL API: Exposes a GraphQL API endpoint for querying and mutating data.
- Cron Jobs: Configures cron jobs for executing periodic tasks.
- Database Connectivity: Establishes a connection to the database.
- CORS: Implements Cross-Origin Resource Sharing for handling requests from different origins.
-
Clone the repository:
git clone
-
Install dependencies:
npm install
-
Set up environment variables:
Create a .env
file in the root directory and specify the required environment variables:
PORT=5000
DATABASE_URL=<your-database-url>
-
Start the server:
npm start
The server will be running on http://localhost:5000
by default.
- Access the GraphQL Playground:
Open a web browser and navigate to http://localhost:5000/graphql
to access the GraphQL Playground. Here, you can interact with the GraphQL API, explore the schema, and execute queries and mutations.
- Port: You can specify a custom port by setting the
PORT
environment variable. - Database: Update the
DATABASE_URL
environment variable with your database connection URL. - Cron Jobs: Define your cron job configurations in the
cron.js
file.
schema/
: Contains the GraphQL schema definitions.helpers/
: Includes helper functions, such as database connection setup.cron.js
: Configures cron jobs.server.js
: Entry point for the Express server.
express
: Web framework for Node.js.express-graphql
: Middleware for integrating GraphQL with Express.cors
: Middleware for enabling Cross-Origin Resource Sharing.cron
: Library for scheduling cron jobs.
Contributions are welcome! Feel free to submit issues or pull requests.