Comparing version 0.0.10 to 0.0.11
{ | ||
"name": "create-oc", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "", |
@@ -26,7 +26,7 @@ { | ||
"devDependencies": { | ||
"oc-server": "*", | ||
"oc-template-elm-compiler": "*", | ||
"elm": "*", | ||
"typescript": "*" | ||
"oc-server": "^0.3.0", | ||
"oc-template-elm-compiler": "^0.3.0", | ||
"elm": "^0.19.1-6", | ||
"typescript": "^5.3.3" | ||
} | ||
} |
@@ -7,9 +7,8 @@ { | ||
"files": { | ||
"data": "server.js", | ||
"data": "src/server.ts", | ||
"static": [ | ||
"img", | ||
"css" | ||
"public" | ||
], | ||
"template": { | ||
"src": "view.js", | ||
"src": "src/view.ts", | ||
"type": "oc-template-es6" | ||
@@ -19,8 +18,8 @@ } | ||
"parameters": { | ||
"name": { | ||
"default": "Jane Doe", | ||
"description": "Your name", | ||
"example": "Jane Doe", | ||
"mandatory": false, | ||
"type": "string" | ||
"userId": { | ||
"default": 1, | ||
"description": "The user id from the user database", | ||
"example": 1, | ||
"mandatory": true, | ||
"type": "number" | ||
} | ||
@@ -30,5 +29,5 @@ } | ||
"devDependencies": { | ||
"oc-server": "*", | ||
"oc-template-es6-compiler": "*" | ||
"oc-server": "^0.3.0", | ||
"oc-template-es6-compiler": "^4.0.3" | ||
} | ||
} |
{ | ||
"name": "base-component-react", | ||
"name": "base-component-preact", | ||
"description": "", | ||
@@ -36,4 +36,4 @@ "version": "1.0.0", | ||
"jsdom": "^21.1.1", | ||
"oc-server": "*", | ||
"oc-template-preact-compiler": "0.2.0", | ||
"oc-server": "^0.3.0", | ||
"oc-template-preact-compiler": "^0.4.0", | ||
"preact": "^10.13.2", | ||
@@ -40,0 +40,0 @@ "typescript": "5.0.2", |
import { Server } from 'oc-server'; | ||
import { AdditionalData, ClientProps, OcParameters } from './types'; | ||
const database = [ | ||
{ name: 'John Doe', age: 34, hobbies: ['Swimming', 'Basketball'] }, | ||
{ name: 'Jane Doe', age: 35, hobbies: ['Running', 'Rugby'] } | ||
const userDatabase = [ | ||
{ name: 'John Doe', born: 1986, hobbies: ['Swimming', 'Basketball'] }, | ||
{ name: 'Jane Doe', born: 1991, hobbies: ['Running', 'Rugby'] }, | ||
]; | ||
const yearsFunFactDatabase: Record<number, string> = { | ||
1986: "Halley's Comet made its closest approach to Earth in 1986, visible to the naked eye.", | ||
1987: 'The first Final Fantasy game was released in 1987.', | ||
1991: 'The first web page was created in 1991 by Tim Berners-Lee.', | ||
}; | ||
async function getUser(userId: number) { | ||
return database[userId]; | ||
return userDatabase[userId]; | ||
} | ||
export const server = new Server(async (params: OcParameters): Promise<ClientProps> => { | ||
const user = await getUser(params.userId); | ||
async function getFunFact(year: number) { | ||
return yearsFunFactDatabase[year]; | ||
} | ||
export const server = new Server(async (params: { userId: number }) => { | ||
const { userId } = params; | ||
const user = await getUser(userId); | ||
const [firstName, lastName] = user.name.split(/\s+/); | ||
if (firstName === 'Invalid') { | ||
return; | ||
} | ||
return { | ||
userId: params.userId, | ||
firstName, | ||
lastName | ||
lastName, | ||
born: user.born, | ||
hobbies: user.hobbies, | ||
}; | ||
}).action('getMoreData', async (params: OcParameters): Promise<AdditionalData> => { | ||
const user = await getUser(params.userId); | ||
}).action('funFact', async (params: { year: number }) => { | ||
const { year } = params; | ||
const funFact = await getFunFact(year); | ||
return { | ||
age: user.age, | ||
hobbies: user.hobbies | ||
funFact, | ||
}; | ||
@@ -29,0 +44,0 @@ }); |
@@ -23,3 +23,7 @@ { | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "preact" | ||
"jsxImportSource": "preact", | ||
"paths": { | ||
"react": ["./node_modules/preact/compat/"], | ||
"react-dom": ["./node_modules/preact/compat/"] | ||
} | ||
}, | ||
@@ -26,0 +30,0 @@ "include": ["src"], |
@@ -37,4 +37,4 @@ { | ||
"jsdom": "^21.1.1", | ||
"oc-server": "*", | ||
"oc-template-react-compiler": "^6.0.0", | ||
"oc-server": "^0.3.0", | ||
"oc-template-react-compiler": "^6.1.0", | ||
"react": "18.2.0", | ||
@@ -41,0 +41,0 @@ "react-dom": "18.2.0", |
@@ -37,3 +37,3 @@ import { Server } from 'oc-server'; | ||
}; | ||
}).action('getMoreData', async (params: { year: number }) => { | ||
}).action('funFact', async (params: { year: number }) => { | ||
const { year } = params; | ||
@@ -40,0 +40,0 @@ const funFact = await getFunFact(year); |
@@ -36,4 +36,4 @@ { | ||
"jsdom": "^21.1.1", | ||
"oc-server": "*", | ||
"oc-template-solid-compiler": "*", | ||
"oc-server": "^0.3.0", | ||
"oc-template-solid-compiler": "^0.7.0", | ||
"solid-js": "^1.8.7", | ||
@@ -40,0 +40,0 @@ "typescript": "5.0.2", |
@@ -36,4 +36,4 @@ { | ||
"jsdom": "^21.1.1", | ||
"oc-server": "*", | ||
"oc-template-vue-compiler": "*", | ||
"oc-server": "^0.3.0", | ||
"oc-template-vue-compiler": "^0.2.0", | ||
"typescript": "5.0.2", | ||
@@ -40,0 +40,0 @@ "vitest": "^0.29.7", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
323127
911