@nitronjs/framework 0.1.22 → 0.1.23
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/cli/njs.js +33 -5
- package/lib/Console/Commands/MigrateCommand.js +27 -70
- package/lib/Console/Commands/MigrateFreshCommand.js +49 -66
- package/lib/Console/Commands/MigrateRollbackCommand.js +52 -0
- package/lib/Console/Commands/MigrateStatusCommand.js +38 -0
- package/lib/Console/Commands/SeedCommand.js +36 -65
- package/lib/Core/Paths.js +8 -0
- package/lib/Database/Migration/Checksum.js +23 -0
- package/lib/Database/Migration/MigrationRepository.js +92 -0
- package/lib/Database/Migration/MigrationRunner.js +327 -0
- package/lib/Database/Migration/migrations/0000_00_00_00_00_create_migrations_table.js +21 -0
- package/lib/Database/Migration/migrations/0000_00_00_00_01_create_seeders_table.js +20 -0
- package/lib/Database/Schema/Blueprint.js +0 -40
- package/lib/Database/Schema/Manager.js +29 -40
- package/lib/Database/Seeder/SeederRepository.js +49 -0
- package/lib/Database/Seeder/SeederRunner.js +183 -0
- package/lib/Faker/Data/Address.js +63 -0
- package/lib/Faker/Data/Color.js +72 -0
- package/lib/Faker/Data/Company.js +59 -0
- package/lib/Faker/Data/Date.js +49 -0
- package/lib/Faker/Data/Finance.js +65 -0
- package/lib/Faker/Data/Internet.js +73 -0
- package/lib/Faker/Data/Lorem.js +45 -0
- package/lib/Faker/Data/Person.js +67 -0
- package/lib/Faker/Data/Phone.js +26 -0
- package/lib/Faker/Faker.d.ts +205 -0
- package/lib/Faker/Faker.js +812 -0
- package/lib/View/Manager.js +26 -5
- package/lib/index.d.ts +407 -0
- package/lib/index.js +12 -0
- package/package.json +6 -2
- package/skeleton/config/app.js +20 -0
- package/skeleton/globals.d.ts +68 -1
- package/skeleton/tsconfig.json +6 -16
package/lib/View/Manager.js
CHANGED
|
@@ -9,6 +9,7 @@ import { renderToPipeableStream } from "react-dom/server";
|
|
|
9
9
|
import Log from "../Logging/Manager.js";
|
|
10
10
|
import Route from "../Route/Manager.js";
|
|
11
11
|
import Paths from "../Core/Paths.js";
|
|
12
|
+
import Config from "../Core/Config.js";
|
|
12
13
|
|
|
13
14
|
const CTX = Symbol.for("__nitron_view_context__");
|
|
14
15
|
const MARK = Symbol.for("__nitron_client_component__");
|
|
@@ -520,13 +521,33 @@ ${runtimeScript}${vendorScript}${hydrateScript}
|
|
|
520
521
|
static #setSecurityHeaders(res, nonce) {
|
|
521
522
|
const connectSrc = this.#isDev ? "'self' ws: wss:" : "'self'";
|
|
522
523
|
|
|
524
|
+
// Get CSP whitelist from config
|
|
525
|
+
const cspConfig = Config.get("app.csp", {});
|
|
526
|
+
const whitelist = {
|
|
527
|
+
styles: cspConfig.styles || [],
|
|
528
|
+
fonts: cspConfig.fonts || [],
|
|
529
|
+
images: cspConfig.images || [],
|
|
530
|
+
scripts: cspConfig.scripts || [],
|
|
531
|
+
connect: cspConfig.connect || [],
|
|
532
|
+
frames: cspConfig.frames || [],
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
// Build CSP directives with whitelist
|
|
536
|
+
const styleSrc = ["'self'", "'unsafe-inline'", ...whitelist.styles].join(" ");
|
|
537
|
+
const fontSrc = ["'self'", ...whitelist.fonts].join(" ");
|
|
538
|
+
const imgSrc = ["'self'", "data:", "blob:", ...whitelist.images].join(" ");
|
|
539
|
+
const scriptSrc = ["'self'", `'nonce-${nonce}'`, ...whitelist.scripts].join(" ");
|
|
540
|
+
const connectSrcFinal = [connectSrc, ...whitelist.connect].join(" ");
|
|
541
|
+
const frameSrc = whitelist.frames.length ? whitelist.frames.join(" ") : "'none'";
|
|
542
|
+
|
|
523
543
|
const csp = [
|
|
524
544
|
"default-src 'self'",
|
|
525
|
-
`script-src
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
`connect-src ${
|
|
545
|
+
`script-src ${scriptSrc}`,
|
|
546
|
+
`style-src ${styleSrc}`,
|
|
547
|
+
`img-src ${imgSrc}`,
|
|
548
|
+
`font-src ${fontSrc}`,
|
|
549
|
+
`connect-src ${connectSrcFinal}`,
|
|
550
|
+
`frame-src ${frameSrc}`,
|
|
530
551
|
"frame-ancestors 'self'",
|
|
531
552
|
"base-uri 'self'",
|
|
532
553
|
"form-action 'self'"
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
export class Storage {
|
|
2
|
+
static url(path: string): string;
|
|
3
|
+
static path(path: string): string;
|
|
4
|
+
static disk(name: string): Storage;
|
|
5
|
+
static get(path: string): Promise<Buffer>;
|
|
6
|
+
static put(path: string, contents: string | Buffer): Promise<void>;
|
|
7
|
+
static delete(path: string): Promise<boolean>;
|
|
8
|
+
static exists(path: string): Promise<boolean>;
|
|
9
|
+
static copy(from: string, to: string): Promise<void>;
|
|
10
|
+
static move(from: string, to: string): Promise<void>;
|
|
11
|
+
static files(directory: string): Promise<string[]>;
|
|
12
|
+
static directories(directory: string): Promise<string[]>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class Model {
|
|
16
|
+
static table: string;
|
|
17
|
+
static primaryKey: string;
|
|
18
|
+
static timestamps: boolean;
|
|
19
|
+
static fillable: string[];
|
|
20
|
+
static hidden: string[];
|
|
21
|
+
static casts: Record<string, string>;
|
|
22
|
+
|
|
23
|
+
static all<T extends Model>(this: new () => T): Promise<T[]>;
|
|
24
|
+
static find<T extends Model>(this: new () => T, id: number | string): Promise<T | null>;
|
|
25
|
+
static findOrFail<T extends Model>(this: new () => T, id: number | string): Promise<T>;
|
|
26
|
+
static first<T extends Model>(this: new () => T): Promise<T | null>;
|
|
27
|
+
static where<T extends Model>(this: new () => T, column: string, operator?: any, value?: any): QueryBuilder<T>;
|
|
28
|
+
static select<T extends Model>(this: new () => T, ...columns: string[]): QueryBuilder<T>;
|
|
29
|
+
static orderBy<T extends Model>(this: new () => T, column: string, direction?: 'asc' | 'desc'): QueryBuilder<T>;
|
|
30
|
+
static limit<T extends Model>(this: new () => T, count: number): QueryBuilder<T>;
|
|
31
|
+
static create<T extends Model>(this: new () => T, data: Record<string, any>): Promise<T>;
|
|
32
|
+
|
|
33
|
+
save(): Promise<this>;
|
|
34
|
+
delete(): Promise<boolean>;
|
|
35
|
+
update(data: Record<string, any>): Promise<this>;
|
|
36
|
+
refresh(): Promise<this>;
|
|
37
|
+
toJSON(): Record<string, any>;
|
|
38
|
+
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface QueryBuilder<T> {
|
|
43
|
+
where(column: string, operator?: any, value?: any): QueryBuilder<T>;
|
|
44
|
+
orWhere(column: string, operator?: any, value?: any): QueryBuilder<T>;
|
|
45
|
+
whereIn(column: string, values: any[]): QueryBuilder<T>;
|
|
46
|
+
whereNotIn(column: string, values: any[]): QueryBuilder<T>;
|
|
47
|
+
whereNull(column: string): QueryBuilder<T>;
|
|
48
|
+
whereNotNull(column: string): QueryBuilder<T>;
|
|
49
|
+
whereBetween(column: string, range: [any, any]): QueryBuilder<T>;
|
|
50
|
+
select(...columns: string[]): QueryBuilder<T>;
|
|
51
|
+
orderBy(column: string, direction?: 'asc' | 'desc'): QueryBuilder<T>;
|
|
52
|
+
limit(count: number): QueryBuilder<T>;
|
|
53
|
+
offset(count: number): QueryBuilder<T>;
|
|
54
|
+
get(): Promise<T[]>;
|
|
55
|
+
first(): Promise<T | null>;
|
|
56
|
+
count(): Promise<number>;
|
|
57
|
+
exists(): Promise<boolean>;
|
|
58
|
+
update(data: Record<string, any>): Promise<number>;
|
|
59
|
+
delete(): Promise<number>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class DB {
|
|
63
|
+
static table(name: string): QueryBuilder<any>;
|
|
64
|
+
static raw(sql: string, bindings?: any[]): Promise<any>;
|
|
65
|
+
static rawExpr(expression: string): any;
|
|
66
|
+
static select(sql: string, bindings?: any[]): Promise<any[]>;
|
|
67
|
+
static insert(sql: string, bindings?: any[]): Promise<any>;
|
|
68
|
+
static update(sql: string, bindings?: any[]): Promise<number>;
|
|
69
|
+
static delete(sql: string, bindings?: any[]): Promise<number>;
|
|
70
|
+
static transaction<T>(callback: () => Promise<T>): Promise<T>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export class Schema {
|
|
74
|
+
static create(table: string, callback: (table: Blueprint) => void): Promise<void>;
|
|
75
|
+
static table(table: string, callback: (table: Blueprint) => void): Promise<void>;
|
|
76
|
+
static drop(table: string): Promise<void>;
|
|
77
|
+
static dropIfExists(table: string): Promise<void>;
|
|
78
|
+
static rename(from: string, to: string): Promise<void>;
|
|
79
|
+
static hasTable(table: string): Promise<boolean>;
|
|
80
|
+
static hasColumn(table: string, column: string): Promise<boolean>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface Blueprint {
|
|
84
|
+
id(column?: string): ColumnDefinition;
|
|
85
|
+
bigIncrements(column: string): ColumnDefinition;
|
|
86
|
+
increments(column: string): ColumnDefinition;
|
|
87
|
+
integer(column: string): ColumnDefinition;
|
|
88
|
+
bigInteger(column: string): ColumnDefinition;
|
|
89
|
+
tinyInteger(column: string): ColumnDefinition;
|
|
90
|
+
smallInteger(column: string): ColumnDefinition;
|
|
91
|
+
mediumInteger(column: string): ColumnDefinition;
|
|
92
|
+
float(column: string, precision?: number, scale?: number): ColumnDefinition;
|
|
93
|
+
double(column: string, precision?: number, scale?: number): ColumnDefinition;
|
|
94
|
+
decimal(column: string, precision?: number, scale?: number): ColumnDefinition;
|
|
95
|
+
boolean(column: string): ColumnDefinition;
|
|
96
|
+
string(column: string, length?: number): ColumnDefinition;
|
|
97
|
+
text(column: string): ColumnDefinition;
|
|
98
|
+
mediumText(column: string): ColumnDefinition;
|
|
99
|
+
longText(column: string): ColumnDefinition;
|
|
100
|
+
json(column: string): ColumnDefinition;
|
|
101
|
+
jsonb(column: string): ColumnDefinition;
|
|
102
|
+
date(column: string): ColumnDefinition;
|
|
103
|
+
dateTime(column: string): ColumnDefinition;
|
|
104
|
+
timestamp(column: string): ColumnDefinition;
|
|
105
|
+
timestamps(): void;
|
|
106
|
+
softDeletes(): void;
|
|
107
|
+
binary(column: string): ColumnDefinition;
|
|
108
|
+
uuid(column: string): ColumnDefinition;
|
|
109
|
+
enum(column: string, values: string[]): ColumnDefinition;
|
|
110
|
+
foreign(column: string): ForeignKeyDefinition;
|
|
111
|
+
index(columns: string | string[]): void;
|
|
112
|
+
unique(columns: string | string[]): void;
|
|
113
|
+
primary(columns: string | string[]): void;
|
|
114
|
+
dropColumn(column: string): void;
|
|
115
|
+
dropColumns(...columns: string[]): void;
|
|
116
|
+
renameColumn(from: string, to: string): void;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface ColumnDefinition {
|
|
120
|
+
nullable(): ColumnDefinition;
|
|
121
|
+
default(value: any): ColumnDefinition;
|
|
122
|
+
unique(): ColumnDefinition;
|
|
123
|
+
primary(): ColumnDefinition;
|
|
124
|
+
index(): ColumnDefinition;
|
|
125
|
+
unsigned(): ColumnDefinition;
|
|
126
|
+
autoIncrement(): ColumnDefinition;
|
|
127
|
+
comment(text: string): ColumnDefinition;
|
|
128
|
+
after(column: string): ColumnDefinition;
|
|
129
|
+
first(): ColumnDefinition;
|
|
130
|
+
change(): ColumnDefinition;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface ForeignKeyDefinition {
|
|
134
|
+
references(column: string): ForeignKeyDefinition;
|
|
135
|
+
on(table: string): ForeignKeyDefinition;
|
|
136
|
+
onDelete(action: string): ForeignKeyDefinition;
|
|
137
|
+
onUpdate(action: string): ForeignKeyDefinition;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export class Hash {
|
|
141
|
+
static make(value: string): Promise<string>;
|
|
142
|
+
static check(value: string, hash: string): Promise<boolean>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export class Auth {
|
|
146
|
+
static attempt(credentials: Record<string, any>): Promise<boolean>;
|
|
147
|
+
static login(user: any): Promise<void>;
|
|
148
|
+
static logout(): Promise<void>;
|
|
149
|
+
static check(): boolean;
|
|
150
|
+
static guest(): boolean;
|
|
151
|
+
static user<T = any>(): T | null;
|
|
152
|
+
static id(): number | string | null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export class Session {
|
|
156
|
+
static get<T = any>(key: string, defaultValue?: T): T;
|
|
157
|
+
static set(key: string, value: any): void;
|
|
158
|
+
static has(key: string): boolean;
|
|
159
|
+
static forget(key: string): void;
|
|
160
|
+
static flush(): void;
|
|
161
|
+
static flash(key: string, value: any): void;
|
|
162
|
+
static reflash(): void;
|
|
163
|
+
static keep(...keys: string[]): void;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export class Log {
|
|
167
|
+
static info(message: string, context?: Record<string, any>): void;
|
|
168
|
+
static error(message: string, context?: Record<string, any>): void;
|
|
169
|
+
static warning(message: string, context?: Record<string, any>): void;
|
|
170
|
+
static debug(message: string, context?: Record<string, any>): void;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export class Validator {
|
|
174
|
+
static make(data: Record<string, any>, rules: Record<string, string>): Validator;
|
|
175
|
+
validate(): Promise<void>;
|
|
176
|
+
fails(): boolean;
|
|
177
|
+
passes(): boolean;
|
|
178
|
+
errors(): Record<string, string[]>;
|
|
179
|
+
validated(): Record<string, any>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export class Lang {
|
|
183
|
+
static get(key: string, replacements?: Record<string, any>): string;
|
|
184
|
+
static has(key: string): boolean;
|
|
185
|
+
static locale(): string;
|
|
186
|
+
static setLocale(locale: string): void;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export class DateTime {
|
|
190
|
+
static now(): DateTime;
|
|
191
|
+
static parse(date: string | Date): DateTime;
|
|
192
|
+
static create(year: number, month: number, day: number, hour?: number, minute?: number, second?: number): DateTime;
|
|
193
|
+
format(format: string): string;
|
|
194
|
+
toDate(): Date;
|
|
195
|
+
toISO(): string;
|
|
196
|
+
addDays(days: number): DateTime;
|
|
197
|
+
addMonths(months: number): DateTime;
|
|
198
|
+
addYears(years: number): DateTime;
|
|
199
|
+
subDays(days: number): DateTime;
|
|
200
|
+
subMonths(months: number): DateTime;
|
|
201
|
+
subYears(years: number): DateTime;
|
|
202
|
+
diffInDays(other: DateTime): number;
|
|
203
|
+
diffInMonths(other: DateTime): number;
|
|
204
|
+
diffInYears(other: DateTime): number;
|
|
205
|
+
isBefore(other: DateTime): boolean;
|
|
206
|
+
isAfter(other: DateTime): boolean;
|
|
207
|
+
isSame(other: DateTime): boolean;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export class Str {
|
|
211
|
+
static slug(value: string, separator?: string): string;
|
|
212
|
+
static camel(value: string): string;
|
|
213
|
+
static pascal(value: string): string;
|
|
214
|
+
static snake(value: string): string;
|
|
215
|
+
static kebab(value: string): string;
|
|
216
|
+
static title(value: string): string;
|
|
217
|
+
static upper(value: string): string;
|
|
218
|
+
static lower(value: string): string;
|
|
219
|
+
static ucfirst(value: string): string;
|
|
220
|
+
static lcfirst(value: string): string;
|
|
221
|
+
static random(length?: number): string;
|
|
222
|
+
static uuid(): string;
|
|
223
|
+
static limit(value: string, limit?: number, end?: string): string;
|
|
224
|
+
static plural(value: string): string;
|
|
225
|
+
static singular(value: string): string;
|
|
226
|
+
static contains(haystack: string, needles: string | string[]): boolean;
|
|
227
|
+
static startsWith(haystack: string, needles: string | string[]): boolean;
|
|
228
|
+
static endsWith(haystack: string, needles: string | string[]): boolean;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface PasswordOptions {
|
|
232
|
+
uppercase?: boolean;
|
|
233
|
+
numbers?: boolean;
|
|
234
|
+
symbols?: boolean;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface WeightedItem<T> {
|
|
238
|
+
value: T;
|
|
239
|
+
weight?: number;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export class FakerClass {
|
|
243
|
+
allowDuplicates(): FakerClass;
|
|
244
|
+
reset(): FakerClass;
|
|
245
|
+
firstName(gender?: 'male' | 'female'): string;
|
|
246
|
+
lastName(): string;
|
|
247
|
+
fullName(gender?: 'male' | 'female'): string;
|
|
248
|
+
gender(): string;
|
|
249
|
+
prefix(gender?: 'male' | 'female'): string;
|
|
250
|
+
suffix(): string;
|
|
251
|
+
age(min?: number, max?: number): number;
|
|
252
|
+
birthDate(minAge?: number, maxAge?: number): Date;
|
|
253
|
+
jobTitle(): string;
|
|
254
|
+
jobArea(): string;
|
|
255
|
+
jobType(): string;
|
|
256
|
+
email(firstName?: string, lastName?: string): string;
|
|
257
|
+
username(firstName?: string, lastName?: string): string;
|
|
258
|
+
password(length?: number, options?: PasswordOptions): string;
|
|
259
|
+
url(protocol?: string): string;
|
|
260
|
+
domainName(): string;
|
|
261
|
+
domainWord(): string;
|
|
262
|
+
domainSuffix(): string;
|
|
263
|
+
ip(): string;
|
|
264
|
+
ipv6(): string;
|
|
265
|
+
mac(separator?: string): string;
|
|
266
|
+
port(): number;
|
|
267
|
+
userAgent(): string;
|
|
268
|
+
browser(): { name: string; version: string };
|
|
269
|
+
httpMethod(): string;
|
|
270
|
+
httpStatusCode(): { code: number; message: string };
|
|
271
|
+
mimeType(): string;
|
|
272
|
+
fileExtension(type?: 'image' | 'document' | 'video' | 'audio' | 'archive' | 'code'): string;
|
|
273
|
+
fileName(extension?: string): string;
|
|
274
|
+
slug(wordCount?: number): string;
|
|
275
|
+
streetAddress(): string;
|
|
276
|
+
streetName(): string;
|
|
277
|
+
city(): string;
|
|
278
|
+
state(abbreviated?: boolean): string;
|
|
279
|
+
stateAbbr(): string;
|
|
280
|
+
country(abbreviated?: boolean): string;
|
|
281
|
+
countryCode(): string;
|
|
282
|
+
zipCode(): string;
|
|
283
|
+
latitude(min?: number, max?: number): number;
|
|
284
|
+
longitude(min?: number, max?: number): number;
|
|
285
|
+
coordinates(): { latitude: number; longitude: number };
|
|
286
|
+
direction(): string;
|
|
287
|
+
secondaryAddress(): string;
|
|
288
|
+
fullAddress(): string;
|
|
289
|
+
timeZone(): string;
|
|
290
|
+
phoneNumber(format?: string): string;
|
|
291
|
+
phoneCountryCode(): { country: string; code: string };
|
|
292
|
+
companyName(): string;
|
|
293
|
+
companySuffix(): string;
|
|
294
|
+
industry(): string;
|
|
295
|
+
catchPhrase(): string;
|
|
296
|
+
buzzword(): string;
|
|
297
|
+
department(): string;
|
|
298
|
+
word(): string;
|
|
299
|
+
words(count?: number): string;
|
|
300
|
+
sentence(wordCount?: number): string;
|
|
301
|
+
sentences(count?: number): string;
|
|
302
|
+
paragraph(sentenceCount?: number): string;
|
|
303
|
+
paragraphs(count?: number, separator?: string): string;
|
|
304
|
+
text(length?: number): string;
|
|
305
|
+
past(years?: number, refDate?: Date | string): Date;
|
|
306
|
+
future(years?: number, refDate?: Date | string): Date;
|
|
307
|
+
recent(days?: number): Date;
|
|
308
|
+
soon(days?: number): Date;
|
|
309
|
+
between(from: Date | string, to: Date | string): Date;
|
|
310
|
+
month(abbreviated?: boolean): string;
|
|
311
|
+
weekday(abbreviated?: boolean): string;
|
|
312
|
+
year(min?: number, max?: number): number;
|
|
313
|
+
amount(min?: number, max?: number, decimals?: number, symbol?: string): string;
|
|
314
|
+
currency(): { code: string; name: string; symbol: string };
|
|
315
|
+
currencyCode(): string;
|
|
316
|
+
currencySymbol(): string;
|
|
317
|
+
creditCard(type?: string): string;
|
|
318
|
+
creditCardFormatted(type?: string): string;
|
|
319
|
+
creditCardCVV(): string;
|
|
320
|
+
creditCardExpiry(): string;
|
|
321
|
+
iban(countryCode?: string): string;
|
|
322
|
+
bic(): string;
|
|
323
|
+
transactionType(): string;
|
|
324
|
+
accountType(): string;
|
|
325
|
+
accountNumber(length?: number): string;
|
|
326
|
+
routingNumber(): string;
|
|
327
|
+
bitcoinAddress(): string;
|
|
328
|
+
ethereumAddress(): string;
|
|
329
|
+
cryptoCurrency(): { name: string; symbol: string };
|
|
330
|
+
colorName(): string;
|
|
331
|
+
hexColor(): string;
|
|
332
|
+
rgbColor(): { r: number; g: number; b: number };
|
|
333
|
+
rgbString(): string;
|
|
334
|
+
rgbaString(alpha?: number): string;
|
|
335
|
+
hslColor(): { h: number; s: number; l: number };
|
|
336
|
+
hslString(): string;
|
|
337
|
+
cssColor(): { name: string; hex: string };
|
|
338
|
+
tailwindColor(color?: string, shade?: number): string;
|
|
339
|
+
imageUrl(width?: number, height?: number, category?: string): string;
|
|
340
|
+
avatarUrl(size?: number): string;
|
|
341
|
+
placeholderUrl(width?: number, height?: number, text?: string, bgColor?: string, textColor?: string): string;
|
|
342
|
+
uuid(): string;
|
|
343
|
+
int(min?: number, max?: number): number;
|
|
344
|
+
float(min?: number, max?: number, decimals?: number): number;
|
|
345
|
+
boolean(probability?: number): boolean;
|
|
346
|
+
arrayElement<T>(array: T[]): T;
|
|
347
|
+
arrayElements<T>(array: T[], count?: number): T[];
|
|
348
|
+
objectElement<T>(obj: Record<string, T>): { key: string; value: T };
|
|
349
|
+
shuffle<T>(array: T[]): T[];
|
|
350
|
+
maybe<T>(callback: () => T, probability?: number): T | null;
|
|
351
|
+
times<T>(count: number, callback: (index: number) => T): T[];
|
|
352
|
+
oneOf<T>(...values: T[]): T;
|
|
353
|
+
weightedPick<T>(items: WeightedItem<T>[]): T;
|
|
354
|
+
template(str: string, data?: Record<string, any>): string;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export const Faker: FakerClass;
|
|
358
|
+
|
|
359
|
+
export class Config {
|
|
360
|
+
static get<T = any>(key: string, defaultValue?: T): T;
|
|
361
|
+
static set(key: string, value: any): void;
|
|
362
|
+
static has(key: string): boolean;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export class Route {
|
|
366
|
+
static get(path: string, handler: any): Route;
|
|
367
|
+
static post(path: string, handler: any): Route;
|
|
368
|
+
static put(path: string, handler: any): Route;
|
|
369
|
+
static patch(path: string, handler: any): Route;
|
|
370
|
+
static delete(path: string, handler: any): Route;
|
|
371
|
+
static group(options: Record<string, any>, callback: () => void): void;
|
|
372
|
+
static resource(name: string, controller: any): void;
|
|
373
|
+
name(name: string): Route;
|
|
374
|
+
middleware(...middleware: any[]): Route;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export class Mail {
|
|
378
|
+
static to(address: string): Mail;
|
|
379
|
+
static from(address: string): Mail;
|
|
380
|
+
static subject(subject: string): Mail;
|
|
381
|
+
static html(content: string): Mail;
|
|
382
|
+
static text(content: string): Mail;
|
|
383
|
+
static send(): Promise<void>;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export class AES {
|
|
387
|
+
static encrypt(data: string, key?: string): string;
|
|
388
|
+
static decrypt(encrypted: string, key?: string): string;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export class View {
|
|
392
|
+
static render(template: string, data?: Record<string, any>): Promise<string>;
|
|
393
|
+
static exists(template: string): boolean;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export const MigrationRunner: any;
|
|
397
|
+
export const MigrationRepository: any;
|
|
398
|
+
export const SeederRunner: any;
|
|
399
|
+
export const SeederRepository: any;
|
|
400
|
+
export const Checksum: any;
|
|
401
|
+
export const DatabaseManager: any;
|
|
402
|
+
export const SessionManager: any;
|
|
403
|
+
export const Server: any;
|
|
404
|
+
export const Paths: any;
|
|
405
|
+
export const Environment: any;
|
|
406
|
+
|
|
407
|
+
export function start(): Promise<void>;
|
package/lib/index.js
CHANGED
|
@@ -16,6 +16,15 @@ export { default as Model } from "./Database/Model.js";
|
|
|
16
16
|
export { default as Schema } from "./Database/Schema/Manager.js";
|
|
17
17
|
export { default as DatabaseManager } from "./Database/Manager.js";
|
|
18
18
|
|
|
19
|
+
// Migration
|
|
20
|
+
export { default as MigrationRunner } from "./Database/Migration/MigrationRunner.js";
|
|
21
|
+
export { default as MigrationRepository } from "./Database/Migration/MigrationRepository.js";
|
|
22
|
+
export { default as Checksum } from "./Database/Migration/Checksum.js";
|
|
23
|
+
|
|
24
|
+
// Seeder
|
|
25
|
+
export { default as SeederRunner } from "./Database/Seeder/SeederRunner.js";
|
|
26
|
+
export { default as SeederRepository } from "./Database/Seeder/SeederRepository.js";
|
|
27
|
+
|
|
19
28
|
// Authentication
|
|
20
29
|
export { default as Auth } from "./Auth/Manager.js";
|
|
21
30
|
|
|
@@ -53,5 +62,8 @@ export { default as DateTime } from "./Date/DateTime.js";
|
|
|
53
62
|
// Support
|
|
54
63
|
export { default as Str } from "./Support/Str.js";
|
|
55
64
|
|
|
65
|
+
// Faker
|
|
66
|
+
export { default as Faker } from "./Faker/Faker.js";
|
|
67
|
+
|
|
56
68
|
// Backward Compatibility Aliases
|
|
57
69
|
export { default as Enviroment } from "./Core/Environment.js";
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitronjs/framework",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "NitronJS is a modern and extensible Node.js MVC framework built on Fastify. It focuses on clean architecture, modular structure, and developer productivity, offering built-in routing, middleware, configuration management, CLI tooling, and native React integration for scalable full-stack applications.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"njs": "./cli/njs.js"
|
|
7
7
|
},
|
|
8
|
+
"types": "./lib/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
|
-
".":
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/index.d.ts",
|
|
12
|
+
"import": "./lib/index.js"
|
|
13
|
+
}
|
|
10
14
|
},
|
|
11
15
|
"dependencies": {
|
|
12
16
|
"@babel/parser": "^7.28.5",
|
package/skeleton/config/app.js
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
locale: 'en',
|
|
3
3
|
timezone: 'UTC',
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Content Security Policy (CSP) Whitelist
|
|
7
|
+
*
|
|
8
|
+
* Add trusted external domains for each resource type.
|
|
9
|
+
* These will be appended to the default secure CSP policy.
|
|
10
|
+
*
|
|
11
|
+
* Examples:
|
|
12
|
+
* - Google Fonts: styles: ["https://fonts.googleapis.com"], fonts: ["https://fonts.gstatic.com"]
|
|
13
|
+
* - Cloudflare CDN: scripts: ["https://cdnjs.cloudflare.com"]
|
|
14
|
+
* - Google Analytics: scripts: ["https://www.googletagmanager.com"], connect: ["https://www.google-analytics.com"]
|
|
15
|
+
*/
|
|
16
|
+
csp: {
|
|
17
|
+
styles: [],
|
|
18
|
+
fonts: [],
|
|
19
|
+
images: [],
|
|
20
|
+
scripts: [],
|
|
21
|
+
connect: [],
|
|
22
|
+
frames: [],
|
|
23
|
+
},
|
|
4
24
|
}
|
package/skeleton/globals.d.ts
CHANGED
|
@@ -1 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* NitronJS Global Types
|
|
3
|
+
*
|
|
4
|
+
* Framework types are provided by @nitronjs/framework package.
|
|
5
|
+
* This file only contains global function declarations.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns the CSRF token for the current request.
|
|
10
|
+
* Works on both SSR and client-side.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // In a form
|
|
14
|
+
* <input type="hidden" name="_csrf" value={csrf()} />
|
|
15
|
+
*
|
|
16
|
+
* // In a fetch request
|
|
17
|
+
* fetch('/api/action', {
|
|
18
|
+
* method: 'POST',
|
|
19
|
+
* headers: { 'X-CSRF-Token': csrf() }
|
|
20
|
+
* })
|
|
21
|
+
*/
|
|
22
|
+
declare function csrf(): string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns the URL for a named route.
|
|
26
|
+
* Works on both SSR and client-side.
|
|
27
|
+
*
|
|
28
|
+
* @param name - The route name as defined in routes/web.js
|
|
29
|
+
* @param params - Optional route parameters
|
|
30
|
+
* @example
|
|
31
|
+
* <a href={route('home')}>Home</a>
|
|
32
|
+
* <a href={route('admin.dashboard')}>Dashboard</a>
|
|
33
|
+
* <a href={route('admin.users.edit', { id: 1 })}>Edit User</a>
|
|
34
|
+
*/
|
|
35
|
+
declare function route(name: string, params?: Record<string, any>): string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Returns the current request object.
|
|
39
|
+
* Only works in Server Components during SSR.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Get query parameters
|
|
43
|
+
* const tab = request().query.tab || 'general';
|
|
44
|
+
*
|
|
45
|
+
* // Get URL parameters
|
|
46
|
+
* const id = request().params.id;
|
|
47
|
+
*
|
|
48
|
+
* // Get request method
|
|
49
|
+
* const method = request().method;
|
|
50
|
+
*/
|
|
51
|
+
declare function request(): {
|
|
52
|
+
path: string;
|
|
53
|
+
method: string;
|
|
54
|
+
query: Record<string, any>;
|
|
55
|
+
params: Record<string, any>;
|
|
56
|
+
body: Record<string, any>;
|
|
57
|
+
headers: Record<string, string>;
|
|
58
|
+
cookies: Record<string, string>;
|
|
59
|
+
ip: string;
|
|
60
|
+
isAjax: boolean;
|
|
61
|
+
session: {
|
|
62
|
+
get<T = any>(key: string, defaultValue?: T): T;
|
|
63
|
+
set(key: string, value: any): void;
|
|
64
|
+
has(key: string): boolean;
|
|
65
|
+
forget(key: string): void;
|
|
66
|
+
flash(key: string, value: any): void;
|
|
67
|
+
};
|
|
68
|
+
};
|
package/skeleton/tsconfig.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2022",
|
|
4
4
|
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
6
|
"jsx": "react-jsx",
|
|
7
7
|
"jsxImportSource": "react",
|
|
8
8
|
"lib": ["ES2022", "DOM"],
|
|
@@ -10,24 +10,14 @@
|
|
|
10
10
|
"esModuleInterop": true,
|
|
11
11
|
"skipLibCheck": true,
|
|
12
12
|
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"
|
|
14
|
-
"declaration": true,
|
|
15
|
-
"declarationMap": true,
|
|
16
|
-
"outDir": "./dist",
|
|
17
|
-
"rootDir": "."
|
|
13
|
+
"noEmit": true
|
|
18
14
|
},
|
|
19
15
|
"include": [
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"routes/**/*",
|
|
24
|
-
"resources/**/*",
|
|
25
|
-
"globals.d.ts"
|
|
16
|
+
"./globals.d.ts",
|
|
17
|
+
"./resources/views/**/*.ts",
|
|
18
|
+
"./resources/views/**/*.tsx"
|
|
26
19
|
],
|
|
27
20
|
"exclude": [
|
|
28
|
-
"node_modules"
|
|
29
|
-
"dist",
|
|
30
|
-
"build",
|
|
31
|
-
"storage"
|
|
21
|
+
"node_modules"
|
|
32
22
|
]
|
|
33
23
|
}
|