# nsc-api

> ..

Latest version **0.0.2** (published 2020-01-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install nsc-api
pnpm add nsc-api
yarn add nsc-api
bun add nsc-api
```

## 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.0.2 |
| Published | 2020-01-06 |
| First published | 2020-01-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ygjack414@hotmail.com |
| Maintainers | ygjack |
| Keywords | nsc-api, axios, nsc |

## Links

- npm: https://www.npmjs.com/package/nsc-api
- Repository: https://github.com/nsc-open/nsc-api
- Homepage: https://github.com/nsc-open/nsc-api#readme
- Issues: https://github.com/nsc-open/nsc-api/issues
- npm.io page: https://npm.io/package/nsc-api

## Recent versions

- 0.0.2 (latest) — 2020-01-06
- 0.0.1 — 2020-01-06

## README

### concept

<version>.<group>.<name>

### define
```js
nscAPI.define('v1.user.simpleList', {
  method: 'get',
  url: `/v1/api/users?fields=id,name`
})
nscAPI.define('v2.product.create', product => ({
  method: 'post',
  url: `/v2/products`,
  data: product
}))
nscAPI.define('v3.user.get', function (args) {
  return nscAPI.v1.user.get(args)
})
nscAPI.define('offline.user.create', definition)
nscAPI.define('online.user.create', definition)
nscAPI.define('smart.user.create', function (args) {
  if (online) {
    return nscAPI.online.user.create(args)
  } else {
    return nscAPI.offline.user.create(args)
  }
})
nscAPI.define('smart.*.*', function (args, { group, name }) {
  const version = online ? nscAPI.online : nscAPI.offline
  return version[group][name](args)
})
```

### usage
```js
nscAPI.call('v1.user.get', options)

nscAPI('v1.user.get', options)
nscAPI('v2.product.create', options)
nscAPI.v1.user.get(options)

const { v1: v1API } = nscAPI
v1API.user.get(options)
```

### config
```js
myAPI.config('v1', config)
myAPI.config('v1.project', config)
myAPI.config('v1.project.get', config)
myAPI.config('mock', {
  baseUrl: 'http://mock.com'
})
myAPI.config('v1', {
  baseUrl: 'http://v1.com'
})
```

### intercept
```js
myAPI.intercept('v1', interceptor)
myAPI.intercept('v1.project', interceptor)
myAPI.intercept('v1.project.get', interceptor)
```


### multi instances
already has versions, no need to have different instances.

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