This repository contains the backend server for the project FormsReplica. Follow the steps below to set up and run the server locally.
- Node.js and npm installed on your machine.
- TypeScript installed globally (
npm install -g typescript
).
-
Clone this repository to your local machine:
git clone https://github.com/Augnik03/formsBackend.git
-
Navigate to the backend directory:
cd formsBackend
-
Install the dependencies:
npm i express body-parser npm i --save-dev typescript @types/express @types/node ts-node nodemon npm i --save-dev @types/cors
-
Create a
db.json
file in the src folder of the backend server. -
Define the structure of the JSON file to store submissions. For example:
[ ]
Here it shows an empty array. This structure can be expanded based on your requirements for storing submissions.
-
Start the backend server:
npm run dev
This command will start the server at the specified port (default is 3000).
You can use tools like Postman or cURL to test the API endpoints provided by the server. Here are the available endpoints:
GET /ping
: Always returns true.POST /submit
: Create a new submission with parameters "name", "email", "phone", "github_link", and "stopwatch_time".GET /read?index=<index>
: Retrieve a submission by index.
- The backend server is configured to use a JSON file (
db.json
) as a database for storing submissions. - Ensure that the JSON file is writable by the server process.
- You may need to adjust the port number if port 3000 is already in use on your system.