File: /home/ekspardev/tubisad-backend/src/app/locations/controller/locations.controller.js
const Locations = require("../model/locations.model");
exports.getAllLocations = async (req, res) => {
const locations = await Locations.findAll();
return res.status(200).json({ success: true, status: true, data: locations });
};
exports.createLocation = async (req, res) => {
const {
name,
lat,
lng,
category,
address,
city,
state,
address2
} = req.body;
if (name && lat && lng) {
const location = await Locations.create({
name: name,
lat: lat,
lng: lng,
category: category,
address: address,
city: city,
state: state,
address2: address2
});
return res.status(201).json({ success: true, status: true, message: 'Created!' });
} else {
return res.status(400).json({ success: true, status: false, message: 'Not Created!' });
}
};