<repo_name>proyecto-galeria/proyecto-galeria-backend<file_sep>/controllers/instruction-controller.js
var InstructionModel = require('../models/instruction-model')

function findAll (req, res, next) {
  InstructionModel.find({}, function (err, users) {
    if (err) console.log(err)
    res.send(users)
  })
}
function create (req, res, next) {
  let newUser = new InstructionModel(req.body)
  newUser.save(function (err, user) {
    if (err) console.log(err)
    res.send(user)
  })
}
function update (req, res, next) {
  InstructionModel.findOne({name: req.params.id}, function (err, user) {
    if (err) console.log(err)
    if (req.body.name) user.name = req.body.name
    user.age = req.body.age
    user.save(function (err, savedUser) {
      if (err) console.log(err)
      res.send(savedUser)
    })
  })
}
function remove (req, res, next) {
  InstructionModel.findOne({name: req.params.id}, function (err, res) {
    if (err) console.log(err)
    res.remove()
  })
}

module.exports = {
    findAll,
    create,
    update,
    remove
}<file_sep>/index.js
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
const cors = require('cors')
const InstructionController = require('./controllers/instruction-controller')
const RecordController = require('./controllers/record-controller')

/// set
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())

app.use(cors())

app.get('/api/instructions', InstructionController.findAll)
app.post('/api/instructions', InstructionController.create)
app.put('/api/instructions/:id', InstructionController.update)
app.delete('/api/instructions/:id', InstructionController.remove)

app.get('/api/records', RecordController.findAll)
app.post('/api/records', RecordController.create)
app.put('/api/records/:id', RecordController.update)
app.delete('/api/records/:id', RecordController.remove)

// --------------------------------- Adding static ------------------------
// app.use(express.static('public'))

app.listen(3000, () => console.log('Example app listening on port 3000!'))
<file_sep>/models/schemas.js
var mongoose = require('mongoose')

var InstructionSchema = mongoose.Schema({
    user: {
        type: String,
        required: true
    },
    date: {
        type: Date,
        required: true
    },
    concept: {
        type: String,
        required: true
    },
    description: {
        type: String,
        required: true
    }
})

var RecordSchema = mongoose.Schema({
    user: {
      type: String,
      required: true
    },
    date: {
      type: Date,
      required: true
    },
    name: {
      type: String,
      required: true
    },
    comments: String,
    instruction: {
        type: mongoose.Schema.ObjectId
    },
    photo: String,
    sent: Boolean,
    recipients: [String]
})

module.exports = {
    InstructionSchema,
    RecordSchema
}