Hi JavaScript coders.
We´ve launced a new service for running your JavaScript (ES6) application as a serverless API backend with codehooks.io.
Zero config, built-in NoSQL storage and much more.
Check out the simple Hello world example below.
First install the CLI and login/signup.
$ npm install codehooks -g
$ codehooks login
Create a project with the codehooks create
CLI command.
$ codehooks create mybackend
$ cd mybackend
In the mybackend folder, create a index.js file for your JavaScript.
import app from 'codehooks-js'
// create an API GET endpoint /hello
app.get('/hello', async (req, res) => {
console.log("Look mum I'm running in the cloud");
res.json({"message": "Hello world!"});
});
export default app.init();
Install your NPM dependencies.
npm i codehooks-js
Deploy with the CLI.
$ codehooks deploy
Test the new API with curl (example API key is fake).
curl https://mybackend-x23a.api.codehooks.io/dev/hello -H 'x-apikey: 6e111ea6-6b3a-412d-8f6b-061c816c67c8'
Example output from curl.
{"message": "Hello world!"}
Happy coding and deploying :)
Top comments (0)