Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Example app using the open source package codehooks-mongoDB

This repository contains the source code used in this blog post

Install CLI

npm install codehooks -g

Usage

Clone the example code repository.

git clone https://github.com/RestDB/codehooks-io-examples.git

Navigate to the example app directory.

cd codehooks-io-examples/codehooks-mongodb/myapp

Install app dependencies

npm init es6 -y
npm install codehooks-mongodb codehooks-js codehooks-crudlify express body-parser mongodb debug yup --save

Start the server locally

node app.js

Test the app

Insert a new user record.

curl -X POST \
  'http://localhost:8080/dev/user' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "name": "Ally",
  "email": "[email protected]"
}'

Run a query agains the database.

curl -X GET \
  'http://localhost:8080/dev/user?name=Ally' \
  --header 'Content-Type: application/json' 

Example output.

[
  {
    "_id": "63fb97825f624f479034eb08",
    "active": true,
    "email": "[email protected]",
    "name": "Ally"
  }
]

Deploy the app to the Codehooks cloud

First create a new Codehooks project to hold the app.

coho init

Next deploy the app to the cloud.

coho deploy

Voilá, you now have a backend app that you can develop and run locally, and at the same time deploy directly to the codehooks.io cloud app service.