# tc-core-library-js

> Topcoder Core library for express based microservices

Latest version **2.4.1** (published 2020-10-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install tc-core-library-js
pnpm add tc-core-library-js
yarn add tc-core-library-js
bun add tc-core-library-js
```

## 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 | 2.4.1 |
| Published | 2020-10-08 |
| First published | 2016-05-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 5 |
| Dependencies | 8 |
| Unpacked size | 31.8 KB |
| Known vulnerabilities | 0 (+29 in 3 direct dependencies) |
| Install scripts | no |
| Author | Parth Shah |
| Maintainers | lazybaer |
| Keywords | express, topcoder |

## Links

- npm: https://www.npmjs.com/package/tc-core-library-js
- Repository: https://github.com/appirio-tech/tc-core-library-js
- Homepage: https://github.com/appirio-tech/tc-core-library-js#readme
- Issues: https://github.com/appirio-tech/tc-core-library-js/issues
- npm.io page: https://npm.io/package/tc-core-library-js

## Dependencies (8)

- [axios](https://npm.io/package/axios.md) ^0.19.0
- [bunyan](https://npm.io/package/bunyan.md) ^1.8.12
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [request](https://npm.io/package/request.md) ^2.88.0
- [jwks-rsa](https://npm.io/package/jwks-rsa.md) ^1.6.0
- [millisecond](https://npm.io/package/millisecond.md) ^0.1.2
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [r7insight_node](https://npm.io/package/r7insight_node.md) ^1.8.4

## Recent versions

- 2.4.1 (latest) — 2020-10-08
- 1.0.9 — 2017-05-05
- 1.0.8 — 2016-10-07
- 1.0.7 — 2016-08-11
- 1.0.6 — 2016-08-10
- 1.0.5 — 2016-07-07
- 1.0.4 — 2016-06-17
- 1.0.3 — 2016-05-31
- 1.0.2 — 2016-05-27
- 1.0.1 — 2016-05-27
- 1.0.0 — 2016-05-26

## README

# tc-core-library-js

Library that contains utils, middlewares etc that can be used by all Topocder Services.

## Logger
Sets up a *Bunyan* logger (https://github.com/trentm/node-bunyan) to use with the application logging. If `captureLogs` is enabled logs will be pushed to Logentries using [le_node](https://github.com/logentries/le_node#using-with-bunyan) library.

_*Note:* Bunyan logger was chosen over winston because winston logger tends to flatten json metadata logged along with strings thus overwriting values with the same key name._ You'll have to obtain a token for your app to integrate with logentries


## Util
Functions to wrap response based on V3 API specification.

## Middleware
* jwtAuthenticator

  Authenticates the JWT passed in the request header (`Authorization: Bearer eHsdfsdf3234SSDF... `). `AUTH_SECRET` used to decrypt JWT can be passed in.
  If token is missing, invalid or expired middleware will return a HTTP 403 status. If authenticated, request object is annotated with 'authUser' object (JWT payload) which contains userId and users' roles..

* logger

  logger middleware to be used along with previously described bunyan logger that logs incoming request and response along with the response time and a requestId.
  RequestId is read from 'X-Request-Id' header. In case the request header is not present a unique request id is generated. *A child logger is attached to both request & response objects* for convenience. Please use this logger as it appends requestId to all logs associated with this request.

* permissions

  Based on attribute based access control, this middleware exposes a can() function that
  takes in an request object and a action to evaluate the policy associated with that action.
  Middleware assumes policies are already defined beforehand.

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