{"id":19431790,"url":"https://github.com/nicksp/medium-lite-api-server","last_synced_at":"2025-11-19T07:04:48.906Z","repository":{"id":149880065,"uuid":"87482908","full_name":"nicksp/medium-lite-api-server","owner":"nicksp","description":"Node/Express REST API Server","archived":false,"fork":false,"pushed_at":"2017-06-25T12:51:39.000Z","size":97,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T06:16:09.667Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://medium-lite.herokuapp.com/api","language":"JavaScript","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/nicksp.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":"2017-04-06T23:05:15.000Z","updated_at":"2017-06-25T21:26:25.000Z","dependencies_parsed_at":"2023-07-22T07:01:28.664Z","dependency_job_id":null,"html_url":"https://github.com/nicksp/medium-lite-api-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nicksp/medium-lite-api-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicksp%2Fmedium-lite-api-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicksp%2Fmedium-lite-api-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicksp%2Fmedium-lite-api-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicksp%2Fmedium-lite-api-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicksp","download_url":"https://codeload.github.com/nicksp/medium-lite-api-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicksp%2Fmedium-lite-api-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285200705,"owners_count":27131412,"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","status":"online","status_checked_at":"2025-11-19T02:00:05.673Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-10T14:31:57.904Z","updated_at":"2025-11-19T07:04:48.883Z","avatar_url":"https://github.com/nicksp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Medium Clone API Server\n\n## Getting Started\n\nTo get the Node server running locally:\n\n- Clone the repo `git clone https://github.com/nicksp/medium-lite-api-server.git`\n- `yarn install` to install all the dependencies\n- Install MongoDB Community Edition ([instructions](https://docs.mongodb.com/manual/installation/#tutorials)) and run it by executing `mongod` command.\n- `yarn run dev` to start the local server\n\n## Code Overview\n\n### Dependencies\n\n- [Express](https://github.com/expressjs/express) - the server for handling and routing HTTP requests\n- [express-jwt](https://github.com/auth0/express-jwt) - middleware for validating JWTs for authentication\n- [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) - JsonWebToken implementation for node.js\n- [Mongoose](https://github.com/Automattic/mongoose) - for modeling and mapping MongoDB data to JS\n- [mongoose-unique-validator](https://github.com/blakehaswell/mongoose-unique-validator) - for handling unique validation errors in Mongoose. Mongoose only handles validation at the document level, so a unique index across a collection will throw an exception at the driver level. The `mongoose-unique-validator` plugin helps us by formatting the error like a normal mongoose `ValidationError`.\n- [Passport](https://github.com/jaredhanson/passport) - for handling user authentication\n- [slug](https://github.com/dodo/node-slug) - for encoding titles into a URL-friendly format\n\n### Application Structure\n\n- `app.js` - an entry point to the application. This file defines express server and connects it to MongoDB using mongoose. It also requires the routes and models we're using in the application.\n- `services/` - this directory contains configuration for Passport.\n- `config/` - this folder is a central location for configuration/environment variables.\n- `routes/` - this folder contains the route definitions for the API.\n- `models/` - this directory contains the schema definitions for Mongoose models.\n\n### Error Handling\n\nIn `routes/api/index.js`, we define an error-handling middleware for handling Mongoose's `ValidationError`. This middleware will respond with a 422 status code and format the response to have error messages the clients can understand.\n\n### Authentication\n\nRequests are authenticated using the `Authorization` header with a valid JWT. We define two express middlewares in `routes/auth.js` that can be used to authenticate requests. The `required` middleware configures the `express-jwt` middleware using the application's secret and will return a 401 status code if the request cannot be authenticated. The payload of the JWT can then be accessed from `req.payload` in the endpoint. The `optional` middleware configures the `express-jwt` in the same way as `required`, but will *not* return a 401 status code if the request cannot be authenticated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicksp%2Fmedium-lite-api-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicksp%2Fmedium-lite-api-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicksp%2Fmedium-lite-api-server/lists"}