open-index/open-npm huggingface dataset:
npm package: @phenyl/http-client
Description: Client to PhenylRestApi. you can handle data on server with MongoDB-like operations
Author: Shin Suzuki
Latest version: 4.2.0

# @phenyl/http-client

Client to PhenylRestApi.
you can handle data on server with MongoDB-like operations

## example
```
import PhenylHttpClient from "@phenyl/http-client";

const httpClient = new PhenylHttpClient({
  url: "localhost:8080",
});

await httpClient.insertAndGet({ entityName: "user", value: { id: "user" } });
const { entity: user } = httpClient.get({ entityName: "user", id: "user" }); // { id: 'user' }
```
npm package: @phenyl/http-server
Description: Simple HTTP Server to host PhenylRestApi
Author: Leko
Latest version: 4.2.0

# @phenyl/http-server

Simple HTTP Server to host PhenylRestApi

## example

To create a PhenylHttpServer instance, you need to create a PhenylRestApi instance.

```js
import { createServer } from "http";
import PhenylHttpServer from "@phenyl/http-server";
import PhenylRestApi from "@phenyl/rest-api";
import { createEntityClient } from "@phenyl/memory-db";

const entityClient = createEntityClient();

class NonUserDefinition {
  constructor() {}
}

const functionalGroup = {
  nonUsers: { nonUser: new NonUserDefinition() },
  users: undefined,
  customQueries: undefined,
  customCommands: undefined,
};

const restApiHandler = new PhenylRestApi(functionalGroup, {
  entityClient,
  sessionClient: entityClient.createSessionClient(),
});

const server = new PhenylHttpServer(createServer(), { restApiHandler });

server.listen(8080)
```
npm package: @phenyl/memory-db
Description: volatile memory DB for local mocking
Author: Shin Suzuki
Latest version: 4.2.0

# @phenyl/memory-db

volatile memory DB for local mocking

## usage

```js
import { createEntityClient } from '@phenyl/memory-db'

const entityClient = createEntityClient()

const user1 = {
        id: 'user1',
        name: 'user1'
    }

entityClient.insertOne({
    entityName: 'user',
    value: user1
})

const { entity: user } = entityClient.get({
    entityName: 'user',
    id: 'user1'
})
```

## Installation
```sh
npm install @phenyl/memory-db
```
npm package: @phenyl/mongodb
Description: MongoDB client.
Author: Shin Suzuki
Latest version: 4.2.0

# @phenyl/mongodb

MongoDB client.

## usage
See [here](../rest-api/README.md) if you use phenylMongoDbClient on your server.

```js
import { PhenylMongoDbClient, connect } from "@phenyl/mongodb"

const connection = await connect({
  url: "mongodb://localhost:27017",
  dbname: "mydb",
});

const phenylMongoDbClient = new PhenylMongoDbClient(connection)

await phenylMongoDbClient.insertAndGet({ entityName: "user", value: { id: "user" } })
const { entity: user } = phenylMongoDbClient.get({ entityName: "user", id: "user" })
```
npm package: @phenyl/redux
Description: phenyl wrapper for redux
Author: Shin Suzuki
Latest version: 4.2.0

# @phenyl/redux

State synchronization among Phenyl CentralState(server) and LocalState(client) using Redux.

## usage
Apply phenyl middleware to redux middleware.
PhenylHttpClient instance is required to create phenyl middleware for synchronization with CentralState(server).

```js
import { createMiddleware, reducer } from "@phenyl/redux";
import { createStore, applyMiddleware } from "redux";
import PhenylHttpClient from "@phenyl/http-client";

const httpClient = new PhenylHttpClient({ url: "localhost:8080" });
const middleware = createMiddleware({ client: httpClient });
const enhancer = applyMiddleware(middleware);
const store = createStore(reducer, enhancer);
```

## Installation

```sh
npm install @phenyl/redux
```
npm package: @phenyl/rest-api
Description: REST API logic. Core part of Phenyl.
Author: Shin Suzuki
Latest version: 4.1.0

# @phenyl/rest-api

REST API logic. Core part of Phenyl.

## example

Define a functionalGroup to create a PhenylRestApi instance.
FunctionalGroup is implementation to notify Phenyl about the domain that we want to use.
See [here](../http-server/README.md) for how to set up an http server using PhenylRestApi instance.
See [here](../standards/README.md) for how to create userDefinition and nonUserDefinition.

```js
import {
  createEntityClient as createMongoDBClient,
  connect,
} from "@phenyl/mongodb";
import PhenylRestApi from "@phenyl/rest-api";

const connection = await connect({
  url: "mongodb://localhost:27017",
  dbname: "mydb",
});

const entityClient = createEntityClient(connection);
const sessionClient = entityClient.createSessionClient();

class NonUserDefinition {
  constructor() {}
}

const functionalGroup = {
  nonUsers: { nonUser: new NonUserDefinition() },
  users: undefined,
  customQueries: undefined,
  customCommands: undefined,
};

const restApiHandler = new PhenylRestApi(functionalGroup, {
  entityClient,
  sessionClient,
});
```
npm package: @phenyl/standards
Description: Standards has templates for user definition.
Author: Shin Suzuki
Latest version: 4.2.0

# phenyl/standards

Standards has templates for user definition.

## example
You can define authentication and authorization by extending StandardUserDefinition.
See [here](../rest-api/README.md) for how to create a PhenylRestApi instance using the userDefinition.

```js
import { StandardUserDefinition } from "@phenyl/standards";
import { EntityDefinition } from "@phenyl/interfaces";

class UserDefinition extends StandardUserDefinition {
  constructor(entityClient) {
    super({
      entityClient,
      accountPropName: "email",
      passwordPropName: "password",
      ttl: 1000 * 60 * 60,
    });
  }
}

class NonUserDefinition implements EntityDefinition {
  constructor(entityClient) {
    super({ entityClient });
  }

  async authorize(reqData) {
    const { authType } = reqData.payload;

    if (authType !== "user") {
      return false;
    }

    switch (reqData.method) {
      case "find": {
        if (authType === "user") {
          return true;
        }
        return false;
      }
      default: {
        return false;
      }
    }
  }
}
```