Skip to content

Commit 24e3d3f

Browse files
committed
docs: add examples
1 parent 4ec017e commit 24e3d3f

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

examples/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
USERNAME=""
2+
PASSWORD=""
3+
INSTANCE=""

examples/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env*
2+
!.env.example

examples/_credentials.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { config } from "dotenv";
2+
import { join } from "node:path";
3+
4+
// Load the `.env` file configuration.
5+
config({ path: join(__dirname, ".env") });
6+
7+
export const credentials = {
8+
instance: process.env.INSTANCE!,
9+
password: process.env.PASSWORD!,
10+
username: process.env.USERNAME!
11+
};

examples/crous.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as AppScho from "../src";
2+
import { credentials } from "./_credentials";
3+
4+
void async function main() {
5+
const { token } = await AppScho.login(credentials.instance, credentials.username, credentials.password);
6+
7+
// Retrieve the list of all Crous available for this instance.
8+
const crous = await AppScho.getCrous(credentials.instance, token);
9+
10+
// Let's retrieve restaurants from the first Crous.
11+
const restaurants = await AppScho.getCrousRestaurants(credentials.instance, token, crous[0].id);
12+
console.log(restaurants);
13+
}();

examples/login.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as AppScho from "../src";
2+
import { credentials } from "./_credentials";
3+
4+
void async function main() {
5+
const user = await AppScho.login(credentials.instance, credentials.username, credentials.password);
6+
console.log("Hello", user.firstname, user.lastname, "from establishment", user.program, "!");
7+
}();

0 commit comments

Comments
 (0)