A Node.js REST API providing information about U.S. states, including fun facts, capitals, nicknames, population, and admission dates. Built with Express, MongoDB, and React.
-
Clone the repository:
git clone https://github.com/fduffoo/StateFactsAPI.git cd StateFactsAPI
-
Install dependencies:
npm install
-
Set up environment variables by creating a
.env
file with:DB_URI=mongodb+srv://<username>:<password>@cluster0.mongodb.net/states?retryWrites=true&w=majority PORT=3000
- Development mode:
npm run dev
- Production mode:
npm start
GET /api/states
Retrieves a list of all U.S. states.
GET /api/states/:state
Retrieves detailed information about a specified state.
GET /api/states/:state/details
Retrieves detailed information about the specified state, including population, admission date, capital, and more.
GET /api/states/:state/capital
Returns the capital city of the specified state.
GET /api/states/:state/nickname
Returns the nickname of the specified state.
GET /api/states/:state/admission
Returns the date the state was admitted to the union.
GET /api/states/:state/website
Returns the official website of the specified state.
GET /api/states/:state/flag
Returns the URL of the state flag image.
GET /api/states/:state/socialmedia
Returns the social media links (Twitter and Facebook) of the specified state.
GET /api/states/:state/population
Returns the population of the specified state.
GET /api/states/:state/funfact
Returns a random fun fact for the specified state.
POST /api/states/:state/funfact
Adds new fun facts for the specified state.
PATCH /api/states/:state/funfact
Updates a fun fact for the specified state at a given index.
DELETE /api/states/:state/funfact
Deletes a fun fact for the specified state.
- Node.js
- Express
- React
- MongoDB
- Mongoose
- Jest
- Supertest
- Nodemon (development)
- dotenv (environment variables)