GithubHelp home page GithubHelp logo

homeon's Introduction

Home ON

Setup

  1. npm i
  2. Create file .env with: SESSION_SECRET=<secret>, where <secret> is an unguessable secret string

Development

  1. Make sure you have MongoDB running
  2. npm run dev
  3. Open localhost:8080 in the browser

Python generate App

auto-py-to-exe

Database

list

"id": , "text": , "count": ,

light

check

"name": "check", "check": false, "isset": false

light

"name": "lights", "lights": [ { "name": "salon", "work": true }, { "name": "kuchnia", "work": false }, { "name": "sypialnia", "work": false }, { "name": "łazienka", "work": true } ]

Adding a POST endpoint to the typed API

  1. Create file backend/routes/my-endpoint.ts:
import { z } from "zod";
import { makePostEndpoint } from "./route";

export function myEndpoint(/* pass objects like database here */) {
    return {
        post: makePostEndpoint({
            schema: z.object({
                // example begin
                name: z.string(),
                id: z.number(),
                // example end
            }),
            async handle({ /* params from schema */ }, { login, email }) {
                // DO STUFF HERE
                // return value is sent to the client as JSON
            },
        });
    };
}
  1. Add this to backend/routes/index.ts:
export * from "./my-endpoint";
  1. Add this to app.ts inside the addApi call:
    "my-endpoint": routes.myEndpoint(/* pass objects like database here */),
  1. Use the endpoint in frontend code:
import * as typedApi from "../util/typed-api";

// in an async function
const json = await typedApi.post("my-endpoint", {
    // example begin
    name: "Volper",
    id: 1,
    // example end
});

homeon's People

Contributors

volper212 avatar szyplc avatar c3zario avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.