Skip to content

Commit

Permalink
rename props
Browse files Browse the repository at this point in the history
  • Loading branch information
tot-kristian committed Jul 30, 2024
1 parent 39888a9 commit 77f4ec5
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 29 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ To create your first application with an environment:
```typescript
const application = await nodb.createAppWithEnvironmentAndGetTokens({
appName: "your-application-name",
environmentName: "your-environment-name",
envName: "your-environment-name",
});
```

Expand Down Expand Up @@ -119,7 +119,7 @@ Writing entities is done using writeEntities method for example using todos enti
```typescript
const ids = await nodb.writeEntities({
appName: "your-application-name",
environmentName: "your-environment-name",
envName: "your-environment-name",
entityName: "your-entity-name",
payload: todos
});
Expand All @@ -129,7 +129,7 @@ Or with then/catch:
```typescript
nodb.writeEntities({
appName: "your-application-name",
environmentName: "your-environment-name",
envName: "your-environment-name",
entityName: "your-entity-name",
payload: todos
}).then(console.log); // get the ids
Expand All @@ -141,13 +141,13 @@ Let's make a sample inquiry using .inquire method, useful for RAG applications:
```typescript
const { answer } = await nodb.inquire({
appName: "your-application-name",
environmentName: "your-environment-name",
envName: "your-environment-name",
inquiry: "Which todo has highest priority?",
});
//Or
nodb.inquire({
appName: "your-application-name",
environmentName: "your-environment-name",
envName: "your-environment-name",
inquiry: "Which todo has highest priority?",
}).then(console.log);
```
Expand Down Expand Up @@ -294,7 +294,7 @@ async createEnvironmentInApp(props: PostEnvironmentBody): Promise<PostEnvironmen
#### `deleteEnvironmentFromApp`

```typescript
async deleteEnvironmentFromApp(props: { appName: string; environmentName: string; token?: string }): Promise<boolean>
async deleteEnvironmentFromApp(props: { appName: string; envName: string; token?: string }): Promise<boolean>
```

#### `deleteApplication`
Expand Down
23 changes: 9 additions & 14 deletions src/nodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,16 @@ class Nodb extends NodbWebSocket {
async createApplication(
props: PostApplicationBody,
): Promise<PostApplicationResponse> {
const {
appName,
appImage,
appDescription,
environmentDescription,
environmentName,
} = props;
const { appName, appImage, appDescription, envDescription, envName } =
props;

const result = await this.axios.post<PostApplicationResponse>(
`/apps/${appName}`,
{
image: appImage,
description: appDescription,
environmentName,
environmentDescription,
envName,
envDescription,
},
);
return result.data;
Expand All @@ -222,10 +217,10 @@ class Nodb extends NodbWebSocket {
async createEnvironmentInApp(
props: PostEnvironmentBody,
): Promise<PostEnvironmentResponse> {
const { appName, description, environmentName, token } = props;
const { appName, description, envName, token } = props;

const result = await this.axios.post<PostEnvironmentResponse>(
`/apps/${appName}/${environmentName}`,
`/apps/${appName}/${envName}`,
{
description,
},
Expand All @@ -236,12 +231,12 @@ class Nodb extends NodbWebSocket {

async deleteEnvironmentFromApp(props: {
appName: string;
environmentName: string;
envName: string;
token?: string;
}): Promise<boolean> {
const { appName, environmentName, token } = props;
const { appName, envName, token } = props;
const result = await this.axios.delete<{ found: boolean }>(
`/apps/${appName}/${environmentName}`,
`/apps/${appName}/${envName}`,
{ ...(token && { headers: { token } }) },
);
return result.data.found;
Expand Down
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export type PostApplicationBody = {
appName: string;
appDescription?: string;
appImage?: string;
environmentName?: string;
environmentDescription?: string;
envName?: string;
envDescription?: string;
};

export type PostEnvironmentResponse = {
Expand All @@ -77,7 +77,7 @@ export type PostEnvironmentResponse = {

export type PostEnvironmentBody = {
appName: string;
environmentName: string;
envName: string;
description?: string;
token?: string;
};
Expand Down
2 changes: 1 addition & 1 deletion test/e2e.deleteEntitites.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Nodb delete entities/entity tests", () => {
beforeAll(async () => {
const result = await nodb.createApplication({
appName,
environmentName: envName,
envName,
});

nodb.setToken(result.applicationTokens[0]!.key);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e.getEntities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("Nodb get entities/entity tests", () => {
beforeAll(async () => {
const result = await nodb.createApplication({
appName,
environmentName: envName,
envName,
});

nodb.setToken(result.applicationTokens[0]!.key);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e.rag.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("Nodb rag entities tests ", () => {
beforeAll(async () => {
const result = await nodb.createApplication({
appName,
environmentName: envName,
envName,
});

nodb.setToken(result.applicationTokens[0]!.key);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e.replaceEntities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("Nodb replace entities/entity tests", () => {
beforeAll(async () => {
const result = await nodb.createApplication({
appName,
environmentName: envName,
envName,
});

nodb.setToken(result.applicationTokens[0]!.key);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e.updateEntities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("Nodb update entities/entity tests", () => {
beforeAll(async () => {
const result = await nodb.createApplication({
appName,
environmentName: envName,
envName,
});

nodb.setToken(result.applicationTokens[0]!.key);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e.writeEntities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("Nodb write entities/entity tests ", () => {
beforeAll(async () => {
const result = await nodb.createApplication({
appName,
environmentName: envName,
envName,
});

nodb.setToken(result.applicationTokens[0]!.key);
Expand Down

0 comments on commit 77f4ec5

Please sign in to comment.