# SCF Service Stack Starter

Use cases:

Your cloud function code:

```javascript
const SCFRouter = require('scf-service-stack').router;
exports.main = async (request, context) => {
  const app = new SCFRouter(request);

  app.use(async (req, next) => {
    // middleware
    next();
  });

  app.get('/test/:user', async (req) => {
    return req.params;
  });

  app.post('/login', async () => {
    // return something
  });

  // if there is no mapping routers
  app.use(async (req, next) => {
    throw new Error('no mapping routers');
  });

  return app.serve();
};
```

To test/debug cloud function in your local, you could start a local service:

Your starter.js:

```javascript
const Simulator = require('scf-service-stack').simulator;
const service = require('../../../cloudbase/functions/webservice');
const envConfig = require('./env.json');

const simulator = new Simulator(service, envConfig);
simulator.deploy();
```
