Skip to content
Mohsen Esmaeili edited this page Jul 27, 2018 · 12 revisions


Welcome to the Serendip wiki!

Serendip is a Node.js web service framework written in typescript. and of course, you can use it in your javascript projects.

Guids

  • 📁 Serving static files
  • 🔨 Services
  • 🔑 Authentication
  • 🗃 Database
  • ✉️ Email
  • 📱 Sms | 🌐 sms.ir به همراه سرویس ارسال پیامک برای داخل ایران از
  • 📠 Fax | 🌐 fax.ir به همراه سرویس ارسال فکس برای داخل ایران از
  • 🌟 Clustering | running serendip on multiple cpu cores
  • 🔐 Https
  • 🛡 Cross-Origin Resource Sharing (CORS)
  • 😨 Controller and Router

Installing

Assuming you’ve already installed Node.js, create a directory to hold your pplication, and make that your working directory.

$ mkdir myapp
$ cd myapp

Use the npm init command to create a package.json file for your application. For more information on how package.json works, see Specifics of npm’s package.json handling.

$ npm init This command prompts you for a number of things, such as the name and version of your application. For now, you can simply hit RETURN to accept the defaults for most of them, with the following exception:

entry point: (index.js)

Enter app.js, or whatever you want the name of the main file to be. If you want it to be index.js, hit RETURN to accept the suggested default file name.

Now install Serendip in the myapp directory and save it in the dependencies list. For example:

$ npm install serendip --save

To install Serendip temporarily and not add it to the dependencies list:

$ npm install serendip --no-save

helloWorld.js

var serendip = require('serendip');

class fooController {

    constructor() {

        /**
        * GET /api/foo/hi
        */
        this.hi = {
            method: 'get',
            publicAccess: true,
            actions: [
                (req, res, next, done) => {
                    res.write('<h1>Hello</h1>');
                    next('<h2>World</h2>');
                },
                (req, res, next, done, model) => {
                    res.write(model);
                    done();
                }
            ]
        }
    }
}

serendip.start({
    controllers: [fooController],
    cpuCores: 1,
    httpPort: 3000
});
Clone this wiki locally