🔄 Rename all "twake" instances to "tdrive"
🔄 Rename all "twake" instances to "tdrive"
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Twake backend
|
||||
# Tdrive backend
|
||||
|
||||
## Developer guide
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
1. Clone and install dependencies (assumes that you have Node.js 12 and npm installed. If not, we suggest to use [nvm](https://github.com/nvm-sh/nvm/)):
|
||||
|
||||
```sh
|
||||
git clone git@github.com:Twake/Twake.git
|
||||
cd Twake/Twake/backend/node
|
||||
git clone git@github.com:Tdrive/Tdrive.git
|
||||
cd Tdrive/Tdrive/backend/node
|
||||
npm install
|
||||
```
|
||||
|
||||
@@ -38,15 +38,15 @@ will run unit tests only (`test:unit`). For possible tests to run, check the `pa
|
||||
|
||||
### Command Line Interface (CLI)
|
||||
|
||||
The Twake backend CLI provides a set of commands to manage/use/develop Twake from the `twake-cli` binary.
|
||||
Before to use the CLI, you must `compile` Twake with `npm run build`. Once done, you can get help on on any command with the `--help` flag like `./bin/twake-cli console --help`.
|
||||
The Tdrive backend CLI provides a set of commands to manage/use/develop Tdrive from the `tdrive-cli` binary.
|
||||
Before to use the CLI, you must `compile` Tdrive with `npm run build`. Once done, you can get help on on any command with the `--help` flag like `./bin/tdrive-cli console --help`.
|
||||
|
||||
#### The 'console merge' command
|
||||
|
||||
This command allows to connect to the database configured in the `./config/default.json` file and to "merge" the Twake users and companies into the "Twake Console".
|
||||
This command allows to connect to the database configured in the `./config/default.json` file and to "merge" the Tdrive users and companies into the "Tdrive Console".
|
||||
|
||||
```sh
|
||||
./bin/twake-cli console merge --url http://console.twake.app --client twake-app --secret supersecret
|
||||
./bin/tdrive-cli console merge --url http://console.tdrive.app --client tdrive-app --secret supersecret
|
||||
```
|
||||
|
||||
The simplified console workflow is like (some parts are done in parallel):
|
||||
@@ -90,10 +90,10 @@ In order to illustrate how to create a component, let's create a fake Notificati
|
||||
|
||||
```js
|
||||
// File src/services/notification/index.ts
|
||||
import { TwakeService } from "../../core/platform/framework";
|
||||
import { TdriveService } from "../../core/platform/framework";
|
||||
import NotificationServiceAPI from "./api.ts";
|
||||
|
||||
export default class NotificationService extends TwakeService<NotificationServiceAPI> {
|
||||
export default class NotificationService extends TdriveService<NotificationServiceAPI> {
|
||||
version = "1";
|
||||
name = "notification";
|
||||
service: NotificationServiceAPI;
|
||||
@@ -104,14 +104,14 @@ export default class NotificationService extends TwakeService<NotificationServic
|
||||
}
|
||||
```
|
||||
|
||||
3. Our `NotificationService` class extends the generic `TwakeService` class and we defined the `NotificationServiceAPI` as its generic type parameter. It means that in the platform, the other components will be able to retrieve the component from its name and then consume the API defined in the `NotificationServiceAPI` interface and exposed by the `api` method.
|
||||
We need to create this `NotificationServiceAPI` interface which must extend the `TwakeServiceProvider` from the platform like:
|
||||
3. Our `NotificationService` class extends the generic `TdriveService` class and we defined the `NotificationServiceAPI` as its generic type parameter. It means that in the platform, the other components will be able to retrieve the component from its name and then consume the API defined in the `NotificationServiceAPI` interface and exposed by the `api` method.
|
||||
We need to create this `NotificationServiceAPI` interface which must extend the `TdriveServiceProvider` from the platform like:
|
||||
|
||||
```js
|
||||
// File src/services/notification/api.ts
|
||||
import { TwakeServiceProvider } from "../../core/platform/framework/api";
|
||||
import { TdriveServiceProvider } from "../../core/platform/framework/api";
|
||||
|
||||
export default interface NotificationServiceAPI extends TwakeServiceProvider {
|
||||
export default interface NotificationServiceAPI extends TdriveServiceProvider {
|
||||
|
||||
/**
|
||||
* Send a message to a list of recipients
|
||||
@@ -135,18 +135,18 @@ export class NotificationServiceImpl implements NotificationServiceAPI {
|
||||
}
|
||||
```
|
||||
|
||||
5. `NotificationServiceImpl` now needs to be instanciated from the `NotificationService` class since this is where we choose to keep its reference and expose it. There are several places which can be used to instanciate it, in the constructor itself, or in one of the `TwakeService` lifecycle hooks. The `TwakeService` abstract class has several lifecycle hooks which can be extended by the service implementation for customization pusposes:
|
||||
5. `NotificationServiceImpl` now needs to be instanciated from the `NotificationService` class since this is where we choose to keep its reference and expose it. There are several places which can be used to instanciate it, in the constructor itself, or in one of the `TdriveService` lifecycle hooks. The `TdriveService` abstract class has several lifecycle hooks which can be extended by the service implementation for customization pusposes:
|
||||
|
||||
- `public async doInit(): Promise<this>;` Customize the `init` step of the component. This is generally the place where services are instanciated. From this step, you can retrieve services consumed by the current component which have been already initialized by the platform.
|
||||
- `public async doStart(): Promise<this>;` Customize the `start` step of the component. You have access to all other services which are already started.
|
||||
|
||||
```js
|
||||
// File src/services/notification/index.ts
|
||||
import { TwakeService } from "../../core/platform/framework";
|
||||
import { TdriveService } from "../../core/platform/framework";
|
||||
import NotificationServiceAPI from "./api.ts";
|
||||
import NotificationServiceImpl from "./services/api.ts";
|
||||
|
||||
export default class NotificationService extends TwakeService<NotificationServiceAPI> {
|
||||
export default class NotificationService extends TdriveService<NotificationServiceAPI> {
|
||||
version = "1";
|
||||
name = "notification";
|
||||
service: NotificationServiceAPI;
|
||||
@@ -166,12 +166,12 @@ export default class NotificationService extends TwakeService<NotificationServic
|
||||
6. Now that the service is fully created, we can consume it from any other service in the platform. To do this, we rely on Typescript decorators to define the links between components. For example, let's say that the a `MessageService` needs to call the `NotificationServiceAPI`, we can create the link with the help of the `@Consumes` decorator and get a reference to the `NotificationServiceAPI` by calling the `getProvider` on the component context like:
|
||||
|
||||
```js
|
||||
import { TwakeService, Consumes } from "../../core/platform/framework";
|
||||
import { TdriveService, Consumes } from "../../core/platform/framework";
|
||||
import MessageServiceAPI from "./providapier";
|
||||
import NotificationServiceAPI from "../notification/api";
|
||||
|
||||
@Consumes(["notification"])
|
||||
export default class MessageService extends TwakeService<MessageServiceAPI> {
|
||||
export default class MessageService extends TdriveService<MessageServiceAPI> {
|
||||
|
||||
public async doInit(): Promise<this> {
|
||||
const notificationService = this.context.getProvider<NotificationServiceAPI>("notification");
|
||||
@@ -214,7 +214,7 @@ Then each service can have its own configuration block which is accessible from
|
||||
On the component class side, the configuration object is directly accessible from the `configuration` property like:
|
||||
|
||||
```js
|
||||
export default class WebSocket extends TwakeService<WebSocketAPI> {
|
||||
export default class WebSocket extends TdriveService<WebSocketAPI> {
|
||||
async doInit(): Promise<this> {
|
||||
// get the "path" value, defaults to "/socket" if not defined
|
||||
const path = this.configuration.get < string > ("path", "/socket");
|
||||
@@ -232,7 +232,7 @@ interface AdaptersConfiguration {
|
||||
|
||||
### Platform
|
||||
|
||||
The Twake Platform is built using the component framework described just before and so, is composed of several technical services on which business services can rely on to provide a micro-services based platform.
|
||||
The Tdrive Platform is built using the component framework described just before and so, is composed of several technical services on which business services can rely on to provide a micro-services based platform.
|
||||
|
||||
The current chapter describes the technical services of the plaform, how to use them, how to build business services on top of them...
|
||||
|
||||
@@ -256,12 +256,12 @@ Supported databases are currently [MongoDB](https://www.mongodb.com/) and [Cassa
|
||||
"type": "cassandra",
|
||||
"mongodb": {
|
||||
"uri": "mongodb://localhost:27017",
|
||||
"database": "twake"
|
||||
"database": "tdrive"
|
||||
},
|
||||
"cassandra": {
|
||||
"contactPoints": ["localhost:9042"],
|
||||
"localDataCenter": "datacenter1",
|
||||
"keyspace": "twake"
|
||||
"keyspace": "tdrive"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -273,7 +273,7 @@ In the example above, the `type` is set to `cassandra`, so the `database.cassand
|
||||
|
||||
In order to use Cassandra, we will have to:
|
||||
|
||||
1. Create a keyspace. From the configuration above, the keyspace is `twake`
|
||||
1. Create a keyspace. From the configuration above, the keyspace is `tdrive`
|
||||
2. Create all the required tables
|
||||
|
||||
To achieve these steps, you have to use [cqlsh](https://cassandra.apache.org/doc/latest/tools/cqlsh.html) from a terminal then:
|
||||
@@ -281,13 +281,13 @@ To achieve these steps, you have to use [cqlsh](https://cassandra.apache.org/doc
|
||||
1. Create the keyspace:
|
||||
|
||||
```sh
|
||||
CREATE KEYSPACE twake WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': '2'} AND durable_writes = true;
|
||||
CREATE KEYSPACE tdrive WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': '2'} AND durable_writes = true;
|
||||
```
|
||||
|
||||
2. Create the required tables
|
||||
|
||||
```sh
|
||||
USE twake;
|
||||
USE tdrive;
|
||||
|
||||
CREATE TABLE channels(company_id uuid, workspace_id uuid, id uuid, archivation_date date, archived boolean, channel_group text, description text, icon text, is_default boolean, name text, owner uuid, visibility text, PRIMARY KEY ((company_id, workspace_id), id));
|
||||
```
|
||||
@@ -391,7 +391,7 @@ Services annotated as described above automatically publish events to WebSockets
|
||||
```js
|
||||
const io = require("socket.io-client");
|
||||
|
||||
// Get a JWT token from the Twake API first
|
||||
// Get a JWT token from the Tdrive API first
|
||||
const token =
|
||||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOjEsImlhdCI6MTYwMzE5ODkzMn0.NvQoV9KeWuTNzRvzqbJ5uZCQ8Nmi2rCYQzcKk-WsJJ8";
|
||||
const socket = io.connect("http://localhost:3000", { path: "/socket" });
|
||||
@@ -433,7 +433,7 @@ socket.on("connect", () => {
|
||||
.emit("authenticate", { token })
|
||||
.on("authenticated", () => {
|
||||
// join the /channels room
|
||||
socket.emit("realtime:join", { name: "/channels", token: "twake" });
|
||||
socket.emit("realtime:join", { name: "/channels", token: "tdrive" });
|
||||
socket.on("realtime:join:error", message => {
|
||||
// will fire when join does not provide a valid token
|
||||
console.log("Error on join", message);
|
||||
@@ -514,7 +514,7 @@ socket.on("connect", () => {
|
||||
.emit("authenticate", { token })
|
||||
.on("authenticated", () => {
|
||||
// join the "/channels" room
|
||||
socket.emit("realtime:join", { name: "/channels", token: "twake" });
|
||||
socket.emit("realtime:join", { name: "/channels", token: "tdrive" });
|
||||
|
||||
// will only occur when an action occured on a resource
|
||||
// and if and only if the client joined the room
|
||||
|
||||
Reference in New Issue
Block a user