Skip to content

Commit

Permalink
feat: support deno 2
Browse files Browse the repository at this point in the history
- change denosandboxcode for Deno 2 compatibility
- use twine@0.2.0 in sandbox code
- use dropserver_lib_support 0.2.1 in sandbox code
- change ackend test fixture code for Deno 2 compatibility
  • Loading branch information
teleclimber committed Sep 30, 2024
1 parent 745d160 commit e54bfca
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cmd/ds-host/sandbox/testfixtures/apps/app-as/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ts-ignore
window.DROPSERVER.appRoutes.setCallback();
globalThis.DROPSERVER.appRoutes.setCallback();

console.log(await Deno.readTextFile('data.txt'));

Expand Down
2 changes: 1 addition & 1 deletion cmd/ds-host/sandbox/testfixtures/apps/app-only/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//@ts-ignore
window.DROPSERVER.appRoutes.setCallback();
globalThis.DROPSERVER.appRoutes.setCallback();
console.log('hw');
4 changes: 2 additions & 2 deletions denosandboxcode/approutes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {match} from "https://deno.land/x/path_to_regexp@v6.2.1/index.ts";
import type {MatchFunction} from "https://deno.land/x/path_to_regexp@v6.2.1/index.ts";

import {RouteType, GetAppRoutesCallback} from 'https://deno.land/x/dropserver_lib_support@v0.2.0/mod.ts';
import type {Handler, Path, Auth} from 'https://deno.land/x/dropserver_lib_support@v0.2.0/mod.ts';
import {RouteType, GetAppRoutesCallback} from 'https://deno.land/x/dropserver_lib_support@v0.2.1/mod.ts';
import type {Handler, Path, Auth} from 'https://deno.land/x/dropserver_lib_support@v0.2.1/mod.ts';

import DsServices from './services/services.ts';

Expand Down
4 changes: 2 additions & 2 deletions denosandboxcode/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import libSupportIface from 'https://deno.land/x/dropserver_lib_support@v0.2.0/mod.ts';
import libSupportIface from 'https://deno.land/x/dropserver_lib_support@v0.2.1/mod.ts';

import Metadata from './metadata.ts';
import DsServices from './services/services.ts';
Expand All @@ -12,7 +12,7 @@ import LibSupport from './libsupport.ts';
const metadata = new Metadata;
const services = new DsServices;

const w = <{["DROPSERVER"]?:libSupportIface}>window;
const w = <{["DROPSERVER"]?:libSupportIface}>globalThis;
const libSupport = new LibSupport(metadata, services);
w["DROPSERVER"] = libSupport;

Expand Down
2 changes: 1 addition & 1 deletion denosandboxcode/migrations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {migrationFunction, GetMigrationsCallback} from 'https://deno.land/x/dropserver_lib_support@v0.2.0/mod.ts';
import {migrationFunction, GetMigrationsCallback} from 'https://deno.land/x/dropserver_lib_support@v0.2.1/mod.ts';

// MigrationMeta is what is sent to the host to identify and make use of migration
// Basically should include everything except the actual function
Expand Down
2 changes: 1 addition & 1 deletion denosandboxcode/services/appservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class DsAppService {
}
catch(e) {
console.error('Error getting routes: '+e);
await message.sendError(e.toString());
if (e instanceof Error) await message.sendError(e.toString());
return;
}

Expand Down
2 changes: 1 addition & 1 deletion denosandboxcode/services/execservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function execFnHandler(message: ReceivedMessageI) {
mod = await import(data.file);
}
catch(e) {
await message.sendError(e.toString());
if (e instanceof Error) await message.sendError(e.toString());
return;
}
// we need more ways of saying what we want to execute
Expand Down
4 changes: 2 additions & 2 deletions denosandboxcode/services/migrateservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class MigrationService {
}
catch(e) {
console.error(e);
await message.sendError("Error running migration step: "+i+', '+e.toString());
if (e instanceof Error) await message.sendError("Error running migration step: "+i+', '+e.toString());
return;
}
}
Expand All @@ -91,7 +91,7 @@ export default class MigrationService {
}
catch(e) {
console.error(e);
await message.sendError("Error running migration step: "+i+', '+e.toString());
if (e instanceof Error) await message.sendError("Error running migration step: "+i+', '+e.toString());
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion denosandboxcode/services/migrateservice_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Deno.test({
await service.runStep(2, true);
}
catch(e) {
err = e;
if (e instanceof Error) err = e;
}

if(!err) {
Expand Down
2 changes: 1 addition & 1 deletion denosandboxcode/services/routeserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default class DsRouteServer {
await route.handler(ctx);
}
catch(e) {
this.replyError(reqEvent, e);
if (e instanceof Error) this.replyError(reqEvent, e.toString());
// this error comes from app code, but it may also be from dropserver_app lib
// But that's technically app code. Maybe dropserver_lib_suport can define an error
// That then gets used to indicate a problem at the library level?
Expand Down
2 changes: 1 addition & 1 deletion denosandboxcode/services/routeserver_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Deno.test({
await routeServer.stopServer();
}
catch(e) {
m.sendError(e);
if (e instanceof Error) m.sendError(e.toString());
}
m.sendOK();
}
Expand Down
2 changes: 1 addition & 1 deletion denosandboxcode/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class DsServices {
}
catch(e) {
console.error(e);
m.sendError(e);
if (e instanceof Error) m.sendError(e.toString());
}
m.sendOK();
break;
Expand Down
6 changes: 3 additions & 3 deletions denosandboxcode/services/twine.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Twine from 'https://deno.land/x/twine@0.1.0/twine.ts';
import Twine from 'https://deno.land/x/twine@0.2.0/twine.ts';
export default Twine;

export {
Message,
} from 'https://deno.land/x/twine@0.1.0/twine.ts';
} from 'https://deno.land/x/twine@0.2.0/twine.ts';

export type {
ReceivedMessageI
} from 'https://deno.land/x/twine@0.1.0/twine.ts';
} from 'https://deno.land/x/twine@0.2.0/twine.ts';
2 changes: 1 addition & 1 deletion denosandboxcode/users.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {User} from 'https://deno.land/x/dropserver_lib_support@v0.2.0/mod.ts';
import type {User} from 'https://deno.land/x/dropserver_lib_support@v0.2.1/mod.ts';
import DsServices from './services/services.ts';

const service = 16;
Expand Down

0 comments on commit e54bfca

Please sign in to comment.