DEV Community

Jbee - codehooks.io
Jbee - codehooks.io

Posted on

3 1

Hello world! Serverless JavaScript with codehooks.io

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
Enter fullscreen mode Exit fullscreen mode

Create a project with the codehooks create CLI command.

$ codehooks create mybackend

$ cd mybackend
Enter fullscreen mode Exit fullscreen mode

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();
Enter fullscreen mode Exit fullscreen mode

Install your NPM dependencies.

npm i codehooks-js
Enter fullscreen mode Exit fullscreen mode

Deploy with the CLI.

$ codehooks deploy
Enter fullscreen mode Exit fullscreen mode

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'
Enter fullscreen mode Exit fullscreen mode

Example output from curl.

{"message": "Hello world!"}
Enter fullscreen mode Exit fullscreen mode

Happy coding and deploying :)

AWS Q Developer image

Your AI Code Assistant

Implement features, document your code, or refactor your projects.
Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post