@positronic/template-new-project 0.0.2

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/template/_env ADDED
@@ -0,0 +1,32 @@
1
+ # Development Environment
2
+ NODE_ENV=development
3
+
4
+ # Cloudflare R2 Configuration
5
+ R2_BUCKET_NAME=<%= projectName %>
6
+
7
+ # R2 Credentials (Optional)
8
+ # These are only needed if you want to upload files larger than 100MB
9
+ # Leave these commented out initially - you can configure them later when needed
10
+ #
11
+ # To get these credentials:
12
+ # 1. Log in to your Cloudflare account
13
+ # 2. Go to R2 > Overview
14
+ # 3. Create a bucket named "<%= projectName %>"
15
+ # 4. Create an R2 API token with Object Read & Write permissions
16
+ # 5. Uncomment and fill in the values below
17
+ #
18
+ # R2_ACCESS_KEY_ID=
19
+ # R2_SECRET_ACCESS_KEY=
20
+ # R2_ACCOUNT_ID=
21
+
22
+ # Cloudflare Deployment Configuration
23
+ # Required for 'px deploy' command
24
+ #
25
+ # To get these values:
26
+ # 1. Log in to your Cloudflare account
27
+ # 2. Go to My Profile > API Tokens
28
+ # 3. Create a token with "Cloudflare Workers Scripts:Edit" permission
29
+ # 4. Copy your Account ID from the right sidebar on any Cloudflare page
30
+ #
31
+ # CLOUDFLARE_API_TOKEN=
32
+ # CLOUDFLARE_ACCOUNT_ID=
@@ -0,0 +1,24 @@
1
+ # Dependency directories
2
+ node_modules/
3
+
4
+ # --- Positronic Specific --- #
5
+
6
+ # Local development server directory
7
+ .positronic/
8
+ .env
9
+
10
+ # Cloudflare Wrangler state and temp files
11
+ .wrangler/
12
+
13
+ # Generated TypeScript resource types (uncomment to ignore)
14
+ # resources.d.ts
15
+
16
+ # Mac specific
17
+ .DS_Store
18
+
19
+ dist/
20
+
21
+ # Test coverage
22
+ coverage/
23
+
24
+ .positronic-server.log
@@ -0,0 +1,59 @@
1
+ import { brain as coreBrain, type BrainFunction } from '@positronic/core';
2
+
3
+ /**
4
+ * Base brain factory for this project.
5
+ *
6
+ * This wrapper allows you to configure services once and have them available
7
+ * in all brains throughout your project.
8
+ *
9
+ * To add services:
10
+ * 1. Define your service interfaces
11
+ * 2. Create service instances
12
+ * 3. Call .withServices() on the brain before returning it
13
+ *
14
+ * Example:
15
+ * ```typescript
16
+ * interface ProjectServices {
17
+ * logger: {
18
+ * info: (message: string) => void;
19
+ * error: (message: string) => void;
20
+ * };
21
+ * api: {
22
+ * fetch: (endpoint: string) => Promise<any>;
23
+ * };
24
+ * }
25
+ *
26
+ * export const brain: BrainFunction = (brainConfig) => {
27
+ * return coreBrain(brainConfig)
28
+ * .withServices({
29
+ * logger: {
30
+ * info: (msg) => console.log(`[INFO] <%= '${msg}' %>`),
31
+ * error: (msg) => console.error(`[ERROR] <%= '${msg}' %>`)
32
+ * },
33
+ * api: {
34
+ * fetch: async (endpoint) => {
35
+ * const response = await fetch(`https://api.example.com<%= '${endpoint}' %>`);
36
+ * return response.json();
37
+ * }
38
+ * }
39
+ * });
40
+ * }
41
+ * ```
42
+ *
43
+ * Then in your brain files (in the brains/ directory):
44
+ * ```typescript
45
+ * import { brain } from '../brain.js';
46
+ *
47
+ * export default brain('My Brain')
48
+ * .step('Use Services', async ({ logger, api }) => {
49
+ * logger.info('Fetching data...');
50
+ * const data = await api.fetch('/users');
51
+ * return { users: data };
52
+ * });
53
+ * ```
54
+ */
55
+ export const brain: BrainFunction = (brainConfig) => {
56
+ // For now, just return the core brain without any services.
57
+ // Update this function to add your project-wide services.
58
+ return coreBrain(brainConfig);
59
+ };
@@ -0,0 +1,13 @@
1
+ import { brain } from '../brain.js';
2
+
3
+ const exampleBrain = brain('example')
4
+ .step('Start', ({ state }) => ({
5
+ ...state,
6
+ message: 'Welcome to Positronic!',
7
+ }))
8
+ .step('Finish', ({ state }) => ({
9
+ ...state,
10
+ finalMessage: state.message + ' Your project is set up.',
11
+ }));
12
+
13
+ export default exampleBrain;