pbnkp
pbnkp
DDeno
Created by pbnkp on 11/27/2023 in #help
question.. web push notifications having trouble with modules
Hi. I’m new to Deno. Overall I’ve been happy with is performance and how lightweight and secure it is. The place I’m having trouble is building a successful server with modules. For example, most of the imports I need to use aren’t available anymore. Here’s an example of the code I can’t get modules to import with: import { Application, Router } from 'https://deno.land/x/oak/mod.ts'; import { oakCors } from "https://deno.land/x/cors/mod.ts"; import { json } from "https://deno.land/std/http/server.ts"; import { Application, Router, send } from "https://deno.land/x/oak/mod.ts"; import * as path from "https://deno.land/std/path/mod.ts"; import { webpush } from "https://cdn.skypack.dev/web-push"; import { TextDecoder } from "https://deno.land/std/encoding/utf8.ts"; import { crypto } from "https://deno.land/std/node/crypto.ts"; import { renderFileToString } from "https://deno.land/x/dejs/mod.ts"; import { v4 as uuidv4 } from "https://deno.land/std/uuid/mod.ts"; import { Client } from "https://deno.land/x/mysql/mod.ts"; const app = new Application(); const router = new Router(); const port = 3000; // Database const client = new Client(); await client.connect({ hostname: "localhost", port: 3600, db: "mysql", tls: false, }); const db = client.database("subscriptions"); const subscriptionCollection = db.collection("subscription"); // Middlewares app.use(oakCors()); app.use(json()); // Static files app.use(async (ctx) => { await ctx.send({ root: ${Deno.cwd()}/views, index: "index.html", }); }); // Service Worker Notifications // Generate your own vapid keys by running: // deno run --allow-write --allow-read https://deno.land/x/web_push/cli.ts const publicVapidKey = "<<Public Key>>"; const privateVapidKey = "<<Private Key>>"; webpush.setVapidDetails( "mailto:mail@someEmail.com", publicVapidKey, privateVapidKey );
13 replies