This project contains runnable examples for the interview questions in the supplied markdown notes. Each question is placed in a separate file under examples/.
npm installRun one example at a time because most Express examples use port 3000 and most GraphQL examples use port 4000.
npm run q1
npm run q2
npm run q45For auto-restart while editing:
npm run dev:q1Import this file in Postman:
postman/node_express_graphql_questions_no_secrets.postman_collection.json
Collection variables to set after import:
baseUrl = http://localhost:3000
graphqlUrl = http://localhost:4000
staticToken = secret123
invalidToken = wrongtoken
jwtToken = paste JWT returned from login examplesThe collection avoids hard-coded tokens by using variables like {{staticToken}} and {{jwtToken}}.
| Question | File | Topic |
|---|---|---|
| 1 | examples/01-create-a-basic-express-server.js |
Create a Basic Express Server |
| 2 | examples/02-create-a-custom-logger-middleware.js |
Create a Custom Logger Middleware |
| 3 | examples/03-create-json-body-parsing-middleware.js |
Create JSON Body Parsing Middleware |
| 4 | examples/04-create-authentication-middleware.js |
Create Authentication Middleware |
| 5 | examples/05-attach-user-data-in-middleware.js |
Attach User Data in Middleware |
| 6 | examples/06-role-based-authorization-middleware.js |
Role-Based Authorization Middleware |
| 7 | examples/07-global-error-handling-middleware.js |
Global Error Handling Middleware |
| 8 | examples/08-async-error-handling-wrapper.js |
Async Error Handling Wrapper |
| 9 | examples/09-create-rest-api-crud-without-database.js |
Create REST API CRUD Without Database |
| 10 | examples/10-validate-request-body-without-library.js |
Validate Request Body Without Library |
| 11 | examples/11-validate-request-body-using-zod.js |
Validate Request Body Using Zod |
| 12 | examples/12-pagination-in-rest-api.js |
Pagination in REST API |
| 13 | examples/13-search-and-filter-rest-api.js |
Search and Filter REST API |
| 14 | examples/14-sorting-rest-api-data.js |
Sorting REST API Data |
| 15 | examples/15-jwt-login-api.js |
JWT Login API |
| 16 | examples/16-jwt-protected-api-middleware.js |
JWT Protected API Middleware |
| 17 | examples/17-rate-limiting-middleware.js |
Rate Limiting Middleware |
| 18 | examples/18-cors-middleware-manually.js |
CORS Middleware Manually |
| 19 | examples/19-request-id-middleware.js |
Request ID Middleware |
| 20 | examples/20-api-versioning.js |
API Versioning |
| 21 | examples/21-express-router-based-structure.js |
Express Router-Based Structure |
| 22 | examples/22-upload-file-api-using-multer.js |
Upload File API Using Multer |
| 23 | examples/23-download-file-api.js |
Download File API |
| 24 | examples/24-read-file-using-node-js.js |
Read File Using Node.js |
| 25 | examples/25-stream-large-file-in-api.js |
Stream Large File in API |
| 26 | examples/26-create-graphql-server-with-apollo.js |
Create GraphQL Server with Apollo |
| 27 | examples/27-graphql-query-for-users.js |
GraphQL Query for Users |
| 28 | examples/28-graphql-mutation-to-create-user.js |
GraphQL Mutation to Create User |
| 29 | examples/29-graphql-update-mutation.js |
GraphQL Update Mutation |
| 30 | examples/30-graphql-delete-mutation.js |
GraphQL Delete Mutation |
| 31 | examples/31-nested-graphql-resolver.js |
Nested GraphQL Resolver |
| 32 | examples/32-graphql-pagination.js |
GraphQL Pagination |
| 33 | examples/33-graphql-authentication-using-context.js |
GraphQL Authentication Using Context |
| 34 | examples/34-rest-vs-graphql-coding-comparison.js |
REST vs GraphQL Coding Comparison |
| 35 | examples/35-prevent-n-1-problem-in-graphql.js |
Prevent N+1 Problem in GraphQL |
| 36 | examples/36-build-a-small-rest-api-with-controller-pattern.js |
Build a Small REST API With Controller Pattern |
| 37 | examples/37-build-middleware-chain.js |
Build Middleware Chain |
| 38 | examples/38-middleware-that-stops-request-flow.js |
Middleware That Stops Request Flow |
| 39 | examples/39-handle-404-route.js |
Handle 404 Route |
| 40 | examples/40-full-mini-project-rest-api-middleware.js |
Full Mini Project: REST API + Middleware |
| 41 | examples/41-full-mini-project-graphql-user-api.js |
Full Mini Project: GraphQL User API |
| 42 | examples/42-node-js-promise-based-api-handler.js |
Node.js Promise-Based API Handler |
| 43 | examples/43-timeout-middleware.js |
Timeout Middleware |
| 44 | examples/44-build-api-response-wrapper.js |
Build API Response Wrapper |
| 45 | examples/45-interview-level-combined-question.js |
Interview-Level Combined Question |
- For JWT examples, first call the login request, copy the returned token, and set
jwtTokenin Postman. - For upload example 22, use form-data with field name
file. - For download and stream examples, placeholder files are included in
data/and copied intoexamples/for convenience. - These examples are for learning/interview practice. Do not use hard-coded secrets in production.