create-wirejs-app 2.0.177 → 2.0.179
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/default/.outbox/2026-02-25T23-28-44-056Z-t2vc0jckkfl.json +7 -0
- package/templates/default/api/apps/chat.ts +0 -17
- package/templates/default/api/apps/email.ts +21 -0
- package/templates/default/api/index.ts +2 -0
- package/templates/default/gitignore +1 -0
- package/templates/default/package.json +5 -5
- package/templates/default/src/ssg/admin.ts +8 -10
- package/templates/default/src/ssg/email.ts +57 -0
- package/templates/default/src/ssg/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AuthenticationApi,
|
|
3
3
|
BackgroundJob,
|
|
4
|
-
CronJob,
|
|
5
4
|
RealtimeService,
|
|
6
5
|
withContext,
|
|
7
6
|
} from "wirejs-resources";
|
|
@@ -32,22 +31,6 @@ const counter = new BackgroundJob('app', 'countdowns', {
|
|
|
32
31
|
},
|
|
33
32
|
});
|
|
34
33
|
|
|
35
|
-
new CronJob('app', 'chat-ping', {
|
|
36
|
-
schedule: '*/5 * * * *',
|
|
37
|
-
async handler() {
|
|
38
|
-
const now = new Date();
|
|
39
|
-
const nowString = now.toLocaleString();
|
|
40
|
-
const tzOffset = now.getTimezoneOffset() / 60;
|
|
41
|
-
const tzOffsetString = tzOffset ? `+${tzOffset}` : `-${tzOffset}`;
|
|
42
|
-
const tz = `UTC${tzOffsetString}`;
|
|
43
|
-
|
|
44
|
-
realtimeService.publish('test', [{
|
|
45
|
-
username: 'cron',
|
|
46
|
-
body: `Hi. Just here to let you know what time it is. It's ${nowString} ${tz} ...`
|
|
47
|
-
}])
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
34
|
export const Chat = (auth: AuthenticationApi) => withContext(context => ({
|
|
52
35
|
async publish(room: string, message: string) {
|
|
53
36
|
const user = await auth.requireCurrentUser(context);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AuthenticationApi, EmailSender, withContext } from 'wirejs-resources';
|
|
2
|
+
|
|
3
|
+
const testMailer = new EmailSender('app', 'testMailer', {
|
|
4
|
+
from: 'wirejs-test@thepointless.com'
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export const Mailer = (auth: AuthenticationApi) => withContext(context => ({
|
|
8
|
+
/**
|
|
9
|
+
* Send a test message to yourself.
|
|
10
|
+
*
|
|
11
|
+
* @param body
|
|
12
|
+
*/
|
|
13
|
+
async sendTestMessage(subject: string, body: string) {
|
|
14
|
+
const user = await auth.requireCurrentUser(context);
|
|
15
|
+
await testMailer.send({
|
|
16
|
+
to: user.username,
|
|
17
|
+
body: `This is a test message from your wirejs app:\n\n${body}`,
|
|
18
|
+
subject: `[wirejs test] ${subject}`
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
@@ -5,6 +5,7 @@ import { Wiki } from './apps/wiki.js';
|
|
|
5
5
|
import { Store } from './apps/store.js';
|
|
6
6
|
import { Admin } from './apps/admin.js';
|
|
7
7
|
import { LLM } from './apps/llm/index.js';
|
|
8
|
+
import { Mailer } from './apps/email.js';
|
|
8
9
|
|
|
9
10
|
export type * from './apps/llm/index.js';
|
|
10
11
|
export type * from './apps/todos.js';
|
|
@@ -22,6 +23,7 @@ export const wiki = Wiki(auth);
|
|
|
22
23
|
export const store = Store(auth);
|
|
23
24
|
export const admin = Admin(auth);
|
|
24
25
|
export const llm = LLM(auth);
|
|
26
|
+
export const mailer = Mailer(auth);
|
|
25
27
|
|
|
26
28
|
new Endpoint('app', 'sample-endpoint', {
|
|
27
29
|
description: "Sample endpoint to show programmatic endpoint creation.",
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"dompurify": "^3.2.3",
|
|
13
13
|
"marked": "^15.0.6",
|
|
14
|
-
"wirejs-components": "^0.1.
|
|
14
|
+
"wirejs-components": "^0.1.117",
|
|
15
15
|
"wirejs-dom": "^1.0.44",
|
|
16
|
-
"wirejs-module-payments-stripe": "^0.1.
|
|
17
|
-
"wirejs-resources": "^0.1.
|
|
18
|
-
"wirejs-web-worker": "^1.0.
|
|
16
|
+
"wirejs-module-payments-stripe": "^0.1.68",
|
|
17
|
+
"wirejs-resources": "^0.1.174",
|
|
18
|
+
"wirejs-web-worker": "^1.0.71"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"typescript": "^5.7.3",
|
|
22
|
-
"wirejs-scripts": "^3.0.
|
|
22
|
+
"wirejs-scripts": "^3.0.172"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"prebuild": "npm run prebuild --workspaces --if-present",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { html, list, node, text, hydrate } from 'wirejs-dom/v2';
|
|
2
|
-
import { AuthenticatedContent } from 'wirejs-components';
|
|
3
2
|
import { Main } from '../layouts/main.js';
|
|
4
3
|
import { admin, Endpoint, Setting, SystemAttribute } from 'internal-api';
|
|
5
4
|
|
|
@@ -155,15 +154,14 @@ function Admin() {
|
|
|
155
154
|
|
|
156
155
|
async function App() {
|
|
157
156
|
const self = html`<div id='app'>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
</div>`;
|
|
157
|
+
${node('isAdmin', false, (isAdmin: boolean | undefined) =>
|
|
158
|
+
isAdmin ?
|
|
159
|
+
html`<div><p>Your <b>are</b> an admin.</p>${Admin()}</div>`
|
|
160
|
+
: html`<p>You are <b>NOT</b> an admin.</p>`
|
|
161
|
+
)}
|
|
162
|
+
</div>`.onadd(async self => {
|
|
163
|
+
self.data.isAdmin = await admin.isAdmin(null);
|
|
164
|
+
});
|
|
167
165
|
return self;
|
|
168
166
|
}
|
|
169
167
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { html, list, attribute, hydrate } from 'wirejs-dom/v2';
|
|
2
|
+
import { AuthenticatedContent } from 'wirejs-components';
|
|
3
|
+
import { mailer } from 'internal-api';
|
|
4
|
+
import { Main } from '../layouts/main.js';
|
|
5
|
+
|
|
6
|
+
function Email() {
|
|
7
|
+
const send = async (subject: string, body: string) => {
|
|
8
|
+
try {
|
|
9
|
+
await mailer.sendTestMessage(undefined, subject, body);
|
|
10
|
+
alert("Message sent!");
|
|
11
|
+
} catch {
|
|
12
|
+
alert("Send failed.");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const self = html`<div>
|
|
17
|
+
<h4>Email test</h4>
|
|
18
|
+
<div>
|
|
19
|
+
<form onsubmit=${(event: Event) => {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
const subject = self.data.subject;
|
|
22
|
+
const body = self.data.body;
|
|
23
|
+
self.data.subject = '';
|
|
24
|
+
self.data.body = '';
|
|
25
|
+
send(subject, body);
|
|
26
|
+
}}>
|
|
27
|
+
<p>Subject: <input type='text' value=${attribute('subject', '' as string)} /></p>
|
|
28
|
+
<p>Body: <input type='text' value=${attribute('body', '' as string)} /></p>
|
|
29
|
+
<input type='submit' value='Send' />
|
|
30
|
+
</form>
|
|
31
|
+
</div>
|
|
32
|
+
<div>`;
|
|
33
|
+
|
|
34
|
+
return self;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function App() {
|
|
38
|
+
const self = html`<div id='app'>
|
|
39
|
+
${await AuthenticatedContent({
|
|
40
|
+
authenticated: () => Email(),
|
|
41
|
+
unauthenticated: () => html`<div>
|
|
42
|
+
You need to sign in to send a message.
|
|
43
|
+
</div>`
|
|
44
|
+
})}
|
|
45
|
+
</div>`;
|
|
46
|
+
|
|
47
|
+
return self;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function generate() {
|
|
51
|
+
return Main({
|
|
52
|
+
pageTitle: 'Emailer Test',
|
|
53
|
+
content: await App(),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
hydrate('app', App as any);
|
|
@@ -14,6 +14,7 @@ export async function generate() {
|
|
|
14
14
|
<li><a href='/web-worker-test.html'>Web Worker Test</a></li>
|
|
15
15
|
<li><a href='/storefront.html'>Storefront</a></li>
|
|
16
16
|
<li><a href='/llm-test.html'>LLM Test</a></li>
|
|
17
|
+
<li><a href='/email.html'>Email Test</a></li>
|
|
17
18
|
<li><a href='/admin.html'>Admin</a></li>
|
|
18
19
|
</ul>
|
|
19
20
|
</div>`
|