This is an Express server built with TypeScript that provides three main endpoints: /ping, /submit, and /read.
The server uses a JSON file as a database to store form submissions.
This project includes optional features like deleting and editing submissions, as well as searching for submissions by email.
-
Clone the repository:
git clone https://github.com/shrey258/formsAppBackend.git cd formsAppBackend -
Install dependencies:
npm install
-
Ensure TypeScript and ts-node are installed globally:
npm install -g typescript ts-node
- Start the server using
ts-node:npm run start
The server will be running on http://localhost:3000.
- Method: GET
- Description: Always returns
trueto indicate the server is running. - Response:
true http://localhost:3000/ping
- Method: POST
- Description: Submits a form with the fields
Name,Email,Phone,Github_Link, andStopwatch_Time. - Request Body:
{ "Name": "John Doe", "Email": "john.doe@example.com", "Phone": "1234567890", "Github_Link": "https://github.com/johndoe", "Stopwatch_Time": "00:01:30" } - Response:
Submission successful http://localhost:3000/submit
- Method: GET
- Description: Reads a form submission by its index.
- Query Parameter:
index(0-based) - Response: JSON object with the form submission
http://localhost:3000/read?index=0
- Method: DELETE
- Description: Deletes a form submission by its index.
- Query Parameter:
index(0-based) - Response:
Deletion successful http://localhost:3000/delete?index=2
- Method: PUT
- Description: Edits a form submission by its index.
- Query Parameter:
index(0-based) - Request Body: Any combination of the form fields to update
- Response:
Edit successful http://localhost:3000/edit?index=2
- Method: GET
- Description: Searches for form submissions by email.
- Query Parameter:
email - Response: JSON array of matching form submissions
http://localhost:3000/search?email=<emai-name>
The database is a JSON file (db.json) with an array of submissions. Each submission is an object with the following structure:
{
"Name": "John Doe",
"Email": "john.doe@example.com",
"Phone": "1234567890",
"Github_Link": "https://github.com/johndoe",
"Stopwatch_Time": "00:01:30"
}