made car makes

This commit is contained in:
Jonathan Jara 2025-05-03 17:23:40 -07:00
parent 12b22c6626
commit 9d3f2c7352
3 changed files with 9 additions and 8 deletions

2
app.js
View File

@ -23,7 +23,7 @@ app.get('/', (req, res) => {
app.use('/api/v1/users', userRoutes); app.use('/api/v1/users', userRoutes);
app.use('/api/v1/login', loginRoutes); app.use('/api/v1/login', loginRoutes);
app.use('/api/v1/cars', carsRoutes) app.use('/api/v1/cars', carsRoutes);
app.use((req, res, next) => { app.use((req, res, next) => {
res.status(404).json({ message: 'Route not found' }); res.status(404).json({ message: 'Route not found' });

View File

@ -4,7 +4,7 @@ const CarMake = require('../models/car_makes.js');
// This function retrieves all car makes from the database and sends them as a response. // This function retrieves all car makes from the database and sends them as a response.
exports.getMakes = async (req, res) =>{ exports.getMakes = async (req, res) =>{
try { try {
const makes = await CarMake.find() const makes = await CarMake.find();
res.status(200).json(makes); res.status(200).json(makes);
} catch (error) { } catch (error) {

View File

@ -1,10 +1,11 @@
const { Schema, model } = require('mongoose'); const { Schema, model } = require('mongoose');
const carMakeSchema = new Schema( const carMakeSchema = new Schema(
{ {
make_name: { make_name: {
type: String type: String,
} },
}); }
);
model.exports = model('CarMake', carMakeSchema); module.exports = model('CarMake', carMakeSchema, 'jdm_makes');