# workjs-core

> WorkJS is a NodeJS Web Design Pattern. Use JS annotation (JS Doc) to design your backend service and defined router.

Latest version **0.3.0** (published 2017-08-31) · Apache 2.0 license · 0 weekly downloads

## Install

```sh
npm install workjs-core
pnpm add workjs-core
yarn add workjs-core
bun add workjs-core
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2017-08-31 |
| First published | 2016-08-16 |
| Weekly downloads | 0 |
| License | Apache 2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.x |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| Author | SJ |
| Maintainers | samejack |
| Keywords | workjs, annotation, router |

## Links

- npm: https://www.npmjs.com/package/workjs-core
- Repository: https://samejack@bitbucket.org/samejack/workjs
- Homepage: https://bitbucket.org/samejack/workjs#readme
- npm.io page: https://npm.io/package/workjs-core

## Dependencies (7)

- [cors](https://npm.io/package/cors.md) ^2.7.1
- [basejs](https://npm.io/package/basejs.md) ~1.1.1
- [express](https://npm.io/package/express.md) ~4.12.4
- [winston](https://npm.io/package/winston.md) ^1.0.0
- [node-uuid](https://npm.io/package/node-uuid.md) ^1.4.7
- [socket.io](https://npm.io/package/socket.io.md) ^1.3.0
- [conga-annotations](https://npm.io/package/conga-annotations.md) ^0.1.8

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 0.3.0 (latest) — 2017-08-31
- 0.2.3 — 2017-08-31
- 0.2.2 — 2017-08-23
- 0.2.0 — 2017-08-22
- 0.1.1 — 2016-08-16
- 0.1.0 — 2016-08-16

## README

# WorkJS [![Build Status][travis-image]][travis-url] [![NPM Version][npm-image]][npm-url]
WorkJS is a NodeJS Web Design Pattern (tiny framework!?). Use JS annotation (JS Doc) to design your backend service (API) and defined router as the same time.
WorkJS includes basejs, express and socket.io project. You can build your controller use Object-Oriented Programming.
Write document and defined router at same time. Maybe, you can build your http service quickly.

[npm-image]: https://img.shields.io/npm/v/workjs-core.svg
[npm-url]: https://npmjs.org/package/workjs-core
[travis-image]: https://travis-ci.org/samejack/point-core.svg?branch=master
[travis-url]: https://travis-ci.org/samejack/WorkJS

## Getting Started
#### Install from GitHub
```sh
# get code
$ git clone https://github.com/samejack/WorkJS.git

# install depends package (npm install first)
$ cd WorkJS
$ npm install

# run example
$ npm start
```
Open your browser and go http://127.0.0.1:3000

#### Install from npm package repository
```sh
$ npm install workjs-core
```

## Controller JavaScript Example (book.js)
```javascript
var Base = require('basejs');

var BookController = Base.extend(
  {
    /**
     * Get all book list
     *
     * @Uri("/book")
     * @Method("GET")
     */
    getBookList: function(req, res, workJS) {
    },
    /**
     * Get book information by ISBN
     *
     * @Uri("/book/:isbn")
     * @Method("GET")
     */
    getBookInfo: function(req, res, workJS) {
    },
    /**
     * Create book
     *
     * @Uri("/book")
     * @Method("POST")
     */
    createBook: function(req, res, workJS) {
    },
    /**
     * Modify book
     *
     * @Uri("/book/:isbn")
     * @Method("PUT")
     */
    modifyBook: function(req, res, workJS) {
    },
    /**
     * Delete book
     *
     * @Uri("/book/:isbn")
     * @Method("DELETE")
     */
    deleteBook: function(req, res, workJS) {
    }
  }
);

module.exports = BookController;
```

## Create first WorkJS App

Create a bootstrap JavaScript file (app.js) as follows:
```javascript
var WorkCore = require('workjs-core');

var workCore = new WorkCore({
  // your controller's path
  controllerPath: [__dirname + '/controller']
}).start();
```
Run it
```sh
# run by nodejs
$ sudo node app.js
```
WorkJS default is bind on localhost:80 port. Open your browser and go http://127.0.0.1

## Configrations ([Example](https://github.com/samejack/WorkJS/blob/master/example/app.js))

Parameter | Default | Note
--------- | ------- | ----
port | 3000 | Server port
host | localhost | Server host
controllerPath | ./controller directory | Controller JS file path
cors | true | Enable CORS Header for corss domain web server
staticPath | ./public directory | HTTP document root

## Future Work
* Integrate [APIDoc](https://github.com/samejack/apidoc-core) to defined router.

## License
Apache License 2.0

---
_Source: https://npm.io/package/workjs-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
