Coder Social home page Coder Social logo

fastify-crash-course's Introduction

fastify-crash-course's People

Contributors

bradtraversy avatar jagadeesh-k-2802 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fastify-crash-course's Issues

swagger props, body not working

I've made some changes in the code, if you let me to collaborate, I could push you my branch. ;)

Until than if someone needs a fixed swagger:

const getItemOpts = {
  schema: {
    response: {
      200: Item,
    },
    params: {
      type: "object",
      properties: {
        id: { type: "string" },
      },
    },
  },
  handler: getItem,
}

const postItemOpts = {
  schema: {
    body: {
      type: "object",
      required: ["name"],
      properties: {
        name: { type: "string" },
      },
    },
    response: {
      201: Item,
    },
  },
  handler: addItem,
}

const deleteItemOpts = {
  schema: {
    response: {
      200: {
        type: "object",
        properties: {
          message: { type: "string" },
        },
      },
    },
    params: {
      type: "object",
      properties: {
        id: { type: "string" },
      },
    },
  },
  handler: deleteItem,
}

const updateItemOpts = {
  schema: {
    response: {
      200: Item,
    },
    params: {
      type: "object",
      properties: {
        id: { type: "string" },
      },
    },
    body: {
      type: "object",
      required: ["name"],
      properties: {
        name: { type: "string" },
      },
    },
  },
  handler: updateItem,
}

controllers/getItems function is getting the contents of data file vice what is stored in memory

I can add an item to the list of items. Verified by console.log the array at the last step of addItem controller. When the '/items' get route is hit directly after the add, I am seeing just the contents of the original 3 item array. This is opposite of the youtube tutorial at timecode 30:01 that covers this crash course.

// controller that adds item
const addItem = (req, reply) => {
  const { name } = req.body;
  const newItem = {
    id: uuidv4(),
    name
  };
  items = [...items, newItem];
  reply.code(201).send(newItem);
  console.log(items);
}
// controller that gets all items
let items = require('../items.js');
const { v4: uuidv4 } = require('uuid');
const getItems = (req, reply) => {
  reply.send(items)
}

RequestError: connect ECONNREFUSED from restclient

Thank you for the amazing course on youtube!!!
Best ever!

  • REST Client Version: v0.25.1
  • VSCode Version: Apple silicon Version 1.73
  • OS Version: Monterey 12.6

Steps to Reproduce:
I just git clone all the code.
I have the code
image

I got the error

The connection was rejected. Either the requested service isn’t running on the requested server/port, the proxy settings in vscode are misconfigured, or a firewall is blocking requests. Details: RequestError: connect ECONNREFUSED 127.0.0.1:5000.

image

However, there is no error from the code.

No matter which port I use, I got the same error.

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.