open-index/open-npm huggingface dataset:
npm package: @proerd/nextpress-client
Description: Client-side common things meant to be used along with the `nextpress` project template.
Latest version: 1.1.9-dev1

# nextpress-client

Client-side common things meant to be used along with the `nextpress` project template.

AKA: Where I dump reusable client-side functions.

## Bundled dependencies

Installs a bunch of common libs. Since `node_modules` is a flat tree, requireing them from the consumer project works.

May rely on the package manager used (tested mainly with yarn). Won't work with pnpm.

```
    "@types/classnames": "^2.2.3",
    "@types/next": "^2.4.11",
    "@types/react": "^16.3.14",
    "@types/react-dom": "^16.0.5",
    "@types/react-redux": "^6.0.0",
    "@types/request": "^2.47.1",
    "@types/styled-jsx": "^2.2.3",
    "@types/yup": "^0.24.4",
    "classnames": "^2.2.5",
    "formik": "^0.11.11",
    "react": "^16.4.0",
    "react-dom": "^16.4.0",
    "react-redux": "^5.0.7",
    "redutser": "^0.13.3-t1",
    "redux": "^4.0.0",
    "yup": "^0.25.1"
```

## Common functions

Not exposing them in a main file. Use `require('@proerd/nextpress-client/lib/file')` to get them.
npm package: @proerd/nextpress-context
Description: ## Declare a context mapper
Latest version: 0.1.1

# nextpress-context

## Declare a context mapper

```ts
export const jwtContext = createContextMapper({
  id: 'default.jwt',
  envKeys: ['JWT_SECRET'],
  optionalKeys: [],
  envContext({ getKey }) {
    return {
      jwt: {
        secret: getKey('JWT_SECRET')!,
      },
    }
  },
})
```

## Add it to the global context type

```ts
declare global {
  namespace Nextpress {
    interface CustomContext extends ReturnType<typeof jwtContext['envContext']> {}
  }
}
```

## Declare the application context

```ts
const ctx = ContextFactory({
  //withPrefix: '...',
  projectRoot: __dirname,
  mappers: [jwtContext],
})

console.log(ctx.jwt.secret)
```

- Requires `JWT_SECRET` to be either in the environment variables or in `envfile.env` file;
- Unless `NO_ENVFILE` environment variable is set, throws
  if `envfile.env` does not exist. Also, creates a new preset `envfile.env` according to the required variables
- If `withPrefix` is set, requires variables from a different envfile, `<prefix>envfile.env`. Also requires uppercase prefix to be prepended to each environment variable.

# TSDX Bootstrap

This project was bootstrapped with [TSDX](https://github.com/jaredpalmer/tsdx).