{"id":15588673,"url":"https://github.com/sabinadams/l33t-server","last_synced_at":"2025-03-29T09:29:08.401Z","repository":{"id":103610243,"uuid":"81990275","full_name":"sabinadams/l33t-server","owner":"sabinadams","description":"L33T Server-Side (Node/Express/MongoDB/Pug)","archived":false,"fork":false,"pushed_at":"2023-12-15T17:59:34.000Z","size":17,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T00:59:54.985Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/sabinadams.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}},"created_at":"2017-02-14T21:20:51.000Z","updated_at":"2017-02-24T23:47:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"a3ebf00a-9080-4f16-b835-ea8bb2a8ea12","html_url":"https://github.com/sabinadams/l33t-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabinadams%2Fl33t-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabinadams%2Fl33t-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabinadams%2Fl33t-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabinadams%2Fl33t-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sabinadams","download_url":"https://codeload.github.com/sabinadams/l33t-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246165819,"owners_count":20734111,"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":[],"created_at":"2024-10-02T22:41:16.080Z","updated_at":"2025-03-29T09:29:08.381Z","avatar_url":"https://github.com/sabinadams.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node-Express\nNode/Express/MongoDB/Pug\n\n## What is this?\nThis is just a test project using Express and NodeJS to build a REST API that grabs data from a MongoDB.\nPug/Jade, server-side rendered HTML, is also used on some API endpoints for quick data visualization\n\n## What it does so far\n- The server intercepts all requests and checks for an Authorization header with a bearer token. It then validates that a user in the database has this token before the request is allowed through\n- Grabs, removes, and places data into the badges collection in Mongo\n- Modular File Structure\n- API Endpoints ready for an application to access, and some server generated HTML pages visualizing real data that can be accessed from the server itself\n\n## How to use\n1. Clone this repository\n2. cd into the folder where you stored the project\n3. Run the command: ```npm install```\n4. Run the command: ```npm start```\n  - This will start the live-reload server, which means the server will restart whenever you save a file directly affecting the server's functionality\n  \n## Applicationless Testing\nYou can now reach out to this API if you send a valid Bearer Token in the Authentication header. \nIf you want to just visualize data with no application, follow these instructions:\n  1. Go in to index.js\n  2. Find this section of code\n```javascript\n      app.use((req, res, next) =\u003e {\n        let _authService = new AuthService(db);\n        res.header(\"Access-Control-Allow-Origin\", \"*\");\n        res.header(\"Access-Control-Allow-Headers\", \"Origin, X-Requested-With, Content-Type, Accept, authorization\");\n        res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');\n\n        if(req.method == 'OPTIONS'){\n          res.status(200).send({message: \"Preflight check successful\"});\n        }\n\n        if(req.headers.authorization){\n          let bearer = req.headers.authorization.split(`Bearer `)[1];\n        _authService.verifyToken(bearer, (data) =\u003e {\n          if(data) next();\n          else res.status(401).send({message: \"Not Authenticated\"});\n        });\n        } else {\n        res.status(401).send({message: \"Not Authenticated.\"})\n        next();\n        }\n      })\n   ```\n  3. Under the line   ```let _authService = new AuthService(db);```, place the following: ```req.headers['authorization'] = 'Bearer 12345'```\n  4. Now, after the server has started, in your browser navigate to ```localhost:3000/home``` and you should see a list of badges directly from the database!\n\n## To Do\n1. Login System\n2. Relational data (1 -\u003e many, many -\u003e many) to associate items with users\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabinadams%2Fl33t-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsabinadams%2Fl33t-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabinadams%2Fl33t-server/lists"}