# @uteamjs/node

> @uteamjs/node Restful API framework

Latest version **1.0.4** (published 2021-11-07) · 0 weekly downloads

## Install

```sh
npm install @uteamjs/node
pnpm add @uteamjs/node
yarn add @uteamjs/node
bun add @uteamjs/node
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2021-11-07 |
| First published | 2021-08-15 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 14 |
| Unpacked size | 41.4 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | u.team |
| Maintainers | uteamjs |
| Keywords | Nodejs, Express, @uteamjs |

## Links

- npm: https://www.npmjs.com/package/@uteamjs/node
- Repository: https://github.com/uteamjs/uteam-node
- Homepage: https://github.com/uteamjs/uteam-node#readme
- Issues: https://github.com/uteamjs/uteam-node.git/issues
- npm.io page: https://npm.io/package/@uteamjs/node

## Dependencies (14)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [yaml](https://npm.io/package/yaml.md) ^1.10.2
- [async](https://npm.io/package/async.md) ^3.2.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [moment](https://npm.io/package/moment.md) ^2.29.1
- [express](https://npm.io/package/express.md) ^4.17.1
- [winston](https://npm.io/package/winston.md) ^3.3.3
- [passport](https://npm.io/package/passport.md) ^0.5.0
- [generic-pool](https://npm.io/package/generic-pool.md) ^3.8.2
- [passport-jwt](https://npm.io/package/passport-jwt.md) ^4.0.0
- [sessionstore](https://npm.io/package/sessionstore.md) ^0.4.8
- [cookie-parser](https://npm.io/package/cookie-parser.md) ^1.4.5
- [express-session](https://npm.io/package/express-session.md) ^1.17.2
- [express-fileupload](https://npm.io/package/express-fileupload.md) ^1.2.1

## Recent versions

- 1.0.4 (latest) — 2021-11-07
- 1.0.3 — 2021-11-03
- 1.0.2 — 2021-11-01
- 1.0.1 — 2021-10-28
- 1.0.0 — 2021-08-15

## README

[@uteamjs/node](https://u.team/document/uteam-node/overview) is a backend [RESTful API](https://u.team/document/uteam-node/api) framework built on top of the **Node.js** and **Express.js** ecosystem. It can be deployed alone or together with frontend [@uteamjs/react](https://u.team/document/uteam-react/overview) framework.  It is not required to set up any API endpoint in **Express.js**.  You simply put the backend functions in standard **node_modules** component structure.  This helps to simplify the deployment and management of  complex enterprise applications.

# Features
- Auto API endpoint routing
- Hot loading module
- Simplify database access
- Stateless API with JWT authentication
- Advanced flow control
- Integrate with [@uteamjs/react](https://u.team/document/uteam-react/overview)

# Installation
[uteam CLI](https://u.team/document/uteam-react/overview) helps you automate the creation, deletion and generation of application modules and packages.
```
$ npm install -g uteam
```
Use **uteam create** to create **Node.js** application based on [@uteamjs/node](https://u.team/document/uteam-node/overview) framework:
```
$ uteam create -a tutorial-node -t node-application

```
Change to __...packages/main__ folder, then start the  server:
```
$ node server
```
Refer to [Get Started](https://u.team/document/introduction/getstart) for more details.

# Example
In this following example, the name of the reducer **‘crud-api/contact’** defines the  **\<package>/\<component>** destination.
```jsx    
const reducer = utReducer('crud-api/contact', {
   actions: {
       ...
       load: (_, payload) => _.rows = payload.rows
   }
})

class layout extends utform {
   constructor(props) {
       ...
       props.api('load', {})
   }
   ...
}
```
In the server you need to create a **contact.js** file under the following folder structure:
```
/<project_folder>/your-application/
    ...
    packages/
        crud-api/
            contact.js
            ...
```
Under the **contact.js** file, add the load function:
```jsx
const { sqlseries, capitalize } = require('@uteamjs/node')

exports.load = sqlseries((db, payload) => [
   db.query('select * from contact', rows => {
       rows.forEach(t => t.gender = capitalize(t.gender))
       payload.rows = rows
   })
])
```
The frontend [props.api('load', {})](https://u.team/document/uteam-react/callapi#api) function will be routed to the backend **export.load** function automatically.  

After you execute the query, assign the result rows to the **payload** object.  

Corresponding frontend layout:
```jsx
class layout extends _layout {
   constructor(props) {
       super(props)
       props.api('load', {})
   }

   render = () => this.Content()
}
```
Refer to [CRUD Api tutorial](https://u.team/document/tutorial/crudapi) for more details.
# License
[MIT](LICENSE)

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