{"id":18798619,"url":"https://github.com/liteobject/rest-api-with-express","last_synced_at":"2025-06-17T06:05:50.334Z","repository":{"id":203839354,"uuid":"691856731","full_name":"LiteObject/rest-api-with-express","owner":"LiteObject","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-29T08:57:59.000Z","size":45,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-21T19:13:50.824Z","etag":null,"topics":["express","mongodb","node","nodejs","rest-api","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiteObject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-15T03:22:44.000Z","updated_at":"2023-09-15T03:29:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"3eea1371-3af4-433f-83f6-3ad0ac5fe30b","html_url":"https://github.com/LiteObject/rest-api-with-express","commit_stats":null,"previous_names":["liteobject/rest-api-with-express"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LiteObject/rest-api-with-express","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiteObject%2Frest-api-with-express","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiteObject%2Frest-api-with-express/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiteObject%2Frest-api-with-express/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiteObject%2Frest-api-with-express/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiteObject","download_url":"https://codeload.github.com/LiteObject/rest-api-with-express/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiteObject%2Frest-api-with-express/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260301992,"owners_count":22988721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["express","mongodb","node","nodejs","rest-api","typescript"],"created_at":"2024-11-07T22:12:29.870Z","updated_at":"2025-06-17T06:05:50.312Z","avatar_url":"https://github.com/LiteObject.png","language":"TypeScript","readme":"# REST API Using NodeJS \u0026 Express\n\nHere are step-by-step instructions to create a basic REST API using Node.js, Express, and TypeScript:\n\n## Step 1: Set up a new Node.js project\n\n- Create a new directory for your project.\n- Open a terminal and navigate to the project directory.\n- Run npm init to initialize a new Node.js project. Follow the - prompts to set up your project's details.\n\n## Step 2: Install dependencies\n\nInstall the required dependencies by running the following command:\n\n    npm install express typescript ts-node @types/express\n\n## Step 3: Set up TypeScript configuration\nCreate a `tsconfig.json` file in the root of your project directory.\n\n```shell\nnpx tsc --init\n```\n\nAdd the following content to the `tsconfig.json` file:\n\n```json\n{\n  \"compilerOptions\": {\n    \"target\": \"es6\",\n    \"module\": \"commonjs\",\n    \"outDir\": \"dist\",\n    \"strict\": true,\n    \"esModuleInterop\": true\n  },\n  \"include\": [\"src\"],\n  \"exclude\": [\"node_modules\"]\n}\n```\n\n## Step 4: Create the Express server\n\n- Create a new directory named src in the project root.\n- Inside the src directory, create a new file named server.ts.\n- Add the following code to `server.ts`:\n\n```typescript\nimport express, { Request, Response } from 'express';\n\nconst app = express();\nconst port = 3000;\n\napp.get('/', (req: Request, res: Response) =\u003e {\n  res.send('Hello, World!');\n});\n\napp.listen(port, () =\u003e {\n  console.log(`Server is running on port ${port}`);\n});\n\n```\n\n## Step 5: Build and run the server\n- Open a terminal and navigate to the project directory.\n- Run the following command to compile the TypeScript code:\n\n    ```shell\n    npx tsc\n    ```\n- After the compilation is successful, run the following command to start the server:\n\n    ```shell\n    node dist/server.js\n    ```\n## Step 6: Test the API\n- Open a web browser or use a tool like Postman.\n- Access http://localhost:3000 in the browser or send a GET request to http://localhost:3000 using Postman.\n- You should see the response \"Hello, World!\".","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliteobject%2Frest-api-with-express","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliteobject%2Frest-api-with-express","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliteobject%2Frest-api-with-express/lists"}