Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-oc

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-oc - npm Package Compare versions

Comparing version 0.0.8 to 0.0.10

2

package.json
{
"name": "create-oc",
"version": "0.0.8",
"version": "0.0.10",
"type": "module",

@@ -5,0 +5,0 @@ "description": "",

@@ -38,3 +38,3 @@ {

"oc-server": "*",
"oc-template-react-compiler": "6.0.0",
"oc-template-react-compiler": "^6.0.0",
"react": "18.2.0",

@@ -41,0 +41,0 @@ "react-dom": "18.2.0",

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> => {
async function getFunFact(year: number) {
return yearsFunFactDatabase[year];
}
export const server = new Server(async (params: { userId: number }) => {
const { userId } = params;

@@ -18,14 +27,18 @@ const user = await getUser(userId);

if (firstName === 'Invalid') {
return;
}
return {
userId,
firstName,
lastName
lastName,
born: user.born,
hobbies: user.hobbies,
};
}).action('getMoreData', async (params: OcParameters): Promise<AdditionalData> => {
const { userId } = params;
const user = await getUser(userId);
}).action('getMoreData', async (params: { year: number }) => {
const { year } = params;
const funFact = await getFunFact(year);
return {
age: user.age,
hobbies: user.hobbies
funFact,
};

@@ -32,0 +45,0 @@ });

@@ -7,3 +7,3 @@ {

"lint": "eslint --max-warnings 0 --ext .js,.jsx,.ts,.tsx src",
"build": "tsc --noEmit && oc package .",
"build": "vue-tsc --noEmit && oc package .",
"test": "vitest"

@@ -10,0 +10,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc