Skip to main content

Hello world! The simple serverless backend example

3 simple steps to create your first serverless backend example

  1. Create a project with the coho create CLI command.
  2. Change to the project directory and install npm i codehooks-js -s.
  3. Open index.js in your favorite code editor.
import app from 'codehooks-js'

app.get('/hello', async (req, res) => {
console.log("Inside the routehook");
res.json({"message": "Hello world!"});

export default app.init();

Deploy the serverless backend example with the coho deploy CLI command.

Run coho info --examples to see your API token and cURL examples.

Test API with:

curl https://<PROJECT NAME> -H 'x-apikey: <API TOKEN>'

Test the serverless backend example:

curl -H 'x-apikey: 6e111ea6-6b3a-412d-8f6b-061c816c67c8'

By clicking the "Import" button in Postman and pasting in the cURL expression, you can test the serverless backend example there.