Skip to content
Snippets Groups Projects
server.js 1.94 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jake Read's avatar
    Jake Read committed
    // require express and do things, serve static and then dish a json
    
    
    Jake Read's avatar
    Jake Read committed
    const express = require('express')
    
    Jake Read's avatar
    Jake Read committed
    const exp = express()
    
    // express will serve static files from the client folder 
    exp.use(express.static('client'))
    
    var jd = {
    
    Jake Read's avatar
    Jake Read committed
        parsing: {
            gcode: {
                description: 'gcode parser',
                hasUi: false
            }
        },
        motion: {
            planner: {
                description: 'acceleration lookahead',
                hasUi: true,
                uiPath: 'src/motion/planner/'
            },
            kinematics: {
                description: 'motion to actuator spaces',
                hasUi: false
            },
            controller: {
                description: 'machine state machine',
                hasUi: true,
                uiPath: 'src/motion/controller/'
            }
        },
        motors: {
            stepper: {
                description: 'stepper motor rep',
                hasUi: false
            },
            bldc: {
                description: 'bldc motor rep',
                hasUi: false
            }
        }
    
    Jake Read's avatar
    Jake Read committed
    // can we express this in just a few f'ns?
    // 1st do a req module and place ... link thru run.js - how to place? eval - eval is evil, says most dev.. uses interpreter, not compile 
    
    // can probably think through how to just place, hookup, and change state: altho: how to put async? has to be tied to existing link?
    // arch. now for managing multiple connections? module that does top-level linking, i.e. gets from another machine?
    // can even imagine how to build c and flash
    // but how to run code? put new file and reload with? kritical
    
    exp.get('/modules/list', (req, res) => {
        res.send(jd)
        console.log('get /modules')
    })
    
    // request for new module 
    exp.get('/modules/:moduleHeader/:module', (req, res) => {
    	console.log('req module', req.params)
    })
    
    // put state
    exp.put('/put/:moduleId', (req, res) => {
    
    })
    
    // link or unlink modules
    exp.put('/:link/:moduleId/:output/:moduleId/:input', (req, res) => {
    
    Jake Read's avatar
    Jake Read committed
    
    })
    
    exp.listen(8080, () => console.log("listening on 8080"))
    
    
    Jake Read's avatar
    Jake Read committed
    // put