Skip to content

Commit

Permalink
Merge pull request #52 from winglang/fixing-wing-examples
Browse files Browse the repository at this point in the history
fix(examples): fixing wing examples that were broken
  • Loading branch information
boyney123 authored Aug 20, 2024
2 parents 2816da5 + 8e32b2b commit cd2b3df
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/api-basic-auth-middleware/basic-auth.w
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub class BasicAuth {
}

// force cast to str from str?
return "{authHeader}";
return "{authHeader!}";
} else {
log("headers: {Json.stringify(headers)}");
log("no auth header");
Expand Down
2 changes: 1 addition & 1 deletion examples/api-basic-auth/main.w
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class BasicAuth {
}

// force cast to str from str?
return "{authHeader}";
return "{authHeader!}";
} else {
log("headers: {Json.stringify(headers)}");
log("no auth header");
Expand Down
1 change: 0 additions & 1 deletion examples/multiplayer-videogame/main.w
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
bring cloud;
bring util;
bring ex;
bring expect;

let website = new cloud.Website(path: "./front-end");
Expand Down
4 changes: 2 additions & 2 deletions examples/react-website/main.w
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bring cloud;
bring util;
bring http;
bring ex;
bring react;

let api = new cloud.Api();

Expand All @@ -12,7 +12,7 @@ api.get("/test", inflight (req) => {
};
});

let website = new ex.ReactApp(
let website = new react.App(
projectPath: "./website",
useBuildCommand: true,
localPort: 3002,
Expand Down
5 changes: 5 additions & 0 deletions examples/react-website/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"@winglibs/react": "^0.1.4"
}
}
10 changes: 5 additions & 5 deletions examples/redis/main.w
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
bring cloud;
bring ex;
bring redis;
bring util;
bring expect;

let queue = new cloud.Queue();
let redis = new ex.Redis();
let cache = new redis.Redis();

queue.setConsumer(inflight (message) => {
redis.set("hello", message);
cache.set("hello", message);
}, timeout: 3s);

test "Hello, world!" {
queue.push("world!");
util.waitUntil(() => {
return redis.get("hello") != nil;
return cache.get("hello") != nil;
});

expect.equal(redis.get("hello"), "world!");
expect.equal(cache.get("hello"), "world!");
}
5 changes: 5 additions & 0 deletions examples/redis/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"@winglibs/redis": "^0.0.11"
}
}
12 changes: 6 additions & 6 deletions examples/todo-app/main.w
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
bring cloud;
bring ex;
bring util;
bring http;
bring expect;
bring redis;

enum Status {
PENDING, COMPLETED
Expand Down Expand Up @@ -73,17 +73,17 @@ let convertTaskArrayToJson = inflight (taskArray: Array<Task>): Json => {
********************************************************************/

class TaskStorage impl ITaskStorage {
db: ex.Redis;
db: redis.Redis;
counter: cloud.Counter;

new() {
this.db = new ex.Redis();
this.db = new redis.Redis();
this.counter = new cloud.Counter();
}

inflight _add(id: str, j: Json) {
this.db.set(id , Json.stringify(j));
this.db.sadd("tasks", id);
this.db.sAdd("tasks", id);
}

pub inflight add(description: str): str {
Expand Down Expand Up @@ -120,8 +120,8 @@ class TaskStorage impl ITaskStorage {

pub inflight find(r: IRegExp): Array<Task> {
let result = MutArray<Task>[];
let ids = this.db.smembers("tasks");
for id in ids {
let ids = this.db.sMembers("tasks");
for id in ids ?? [] {
if let taskJsonStr = this.db.get(id) {
let taskJson = Json.parse(taskJsonStr);
if r.test(taskJson.get("description").asStr()) {
Expand Down
5 changes: 5 additions & 0 deletions examples/todo-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"@winglibs/redis": "^0.0.11"
}
}

0 comments on commit cd2b3df

Please sign in to comment.