https://github.com/jeffnyman/devcamper_api
An API for Demonstrating Development and Test Practices
https://github.com/jeffnyman/devcamper_api
api javascript nodejs training-materials
Last synced: 5 months ago
JSON representation
An API for Demonstrating Development and Test Practices
- Host: GitHub
- URL: https://github.com/jeffnyman/devcamper_api
- Owner: jeffnyman
- Created: 2020-06-02T15:10:14.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-07-22T06:37:33.000Z (5 months ago)
- Last Synced: 2025-07-22T08:46:55.434Z (5 months ago)
- Topics: api, javascript, nodejs, training-materials
- Language: JavaScript
- Size: 774 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DevCamper
This project is based on the [DevCamper API](https://github.com/bradtraversy/devcamper-api) created by Brad Traversy.
The goal of this project is to provide a functioning API that serves as the backend for an application that displays developer bootcamp information. My goal in providing this project, based on a well-known example, is to incorporate a testing challenge into it. There is currently no active frontend for this application, so the focus is entirely on building and testing an API.
## Running the API
In order to run the development version of the API, you must have a Mongo database setup, either locally or in the cloud. You then need to provide a `mongodb.env` file in the `config` directory. This file should contain the following environment variable:
```
MONGO_URI = mongodb+srv://:@devcamper-wisqb.mongodb.net/devcamper?retryWrites=true&w=majority
```
Here you have to replace `` and `` with your own credentials. Note that this file is ignored by Git and thus is not checked in as part of the versioning process.
It is also necessary to provide a `geocoder.env` file in the `config` directory that has the following:
```
GEOCODER_API_KEY=
```
Here you have to enter your consumer key from the MapQuest developer setup. This file, too, is not checked in as part of the versioning.
For development purposes, you can start the server with this command:
```
npm run dev
```
You can see the database with the following command:
```
node seeder -i
```
You can also delete the seeded data with the following command:
```
node seeder -d
```
## Testing the API
If you want to run tests, do the following from the project root:
```
npm test
```
As a note on the tests, in order to have them run correctly with the geocoder, you need to create a file called `jestVars.js` in the `config` directory. In that file you will need the following:
```
process.env.GEOCODER_PROVIDER = "mapquest";
process.env.GEOCODER_API_KEY = "";
```
Here you have to enter your consumer key from the MapQuest developer setup. This is required due to how Jest deals with the `process.env` setting. Note that this file will not be included as part of the versioning.
**Test Note:** Currently radius tests do not work. It's unclear to me as to why but I suspect this is another oddity of Jest, a test tool that I'm growing to dislike intensely for all the workarounds I have to do to get it work. Right now what happens is that you can use Postman to clearly see radius calls are working. However, Jest somehow swallows any bootcamps that are returned from an API route that uses something like "radius/02118/10".
## Resource Routes
The resource route structure of the application will be as follows:
- /api/v1/bootcamps
- /api/v1/courses
- /api/v1/reviews
- /api/v1/auth
- /api/v1/users
Right now only the "bootcamps" portion is in place.