concept follow file in category svelte

appears as: following file, following files
Svelte and Sapper in Action

This is an excerpt from Manning's book Svelte and Sapper in Action.

To configure use of ESLint, create the following file in the top directory of each Svelte app:

  • @sapper directory--This directory and its subdirectories contain files provided or generated by Sapper that should not be modified.
    • app.mjs--This file exports the Sapper API functions, including
      • goto for programmatic navigation.
      • start, which configures event handling for page navigation and is called by client.js, which was described earlier.
    • server.mjs--This file exports the Sapper middleware function that processes HTTP requests sent to the app. It is called by server.js, which was described earlier.
    • service-worker.js--This file exports the following constants used by src/ service-worker.js, described earlier.
      • files is an array of static files to be cached by the service worker.
      • shell is an array of files generated by Sapper to be cached by the service worker.
    • internal directory--This contains the following files:
      • App.svelte--This displays the current page, or an error page if there is an error.
      • error.svelte--This is the default error page component that is used if src/routes/_error.svelte is not found. It displays the status code and an error message. It also displays a stack trace if the NODE_ENV environment variable is set to development.
      • layout.svelte--This is the default layout component that is used if src/ routes/_layout.svelte is not found. It only contains a <slot> for rendering the current page component.
      • manifest-client.mjs--This provides data about components and routes (pages). It is used by app.mjs, which was described earlier.
      • manifest-server.mjs--This provides data about server routes (see chapter 17) and pages. It is used by server.mjs, which was described earlier.
      • shared.mjs--This currently doesn’t seem to provide anything useful. Perhaps it will have some purpose in the future.
  • const send = require('@polka/send-type');
    const {ObjectId} = require('mongodb');         #1
    import {getCollection} from '../_helpers';
     
    export async function del(req, res) {          #2
      const {categoryId} = req.params;
      try {
        const collection = await getCollection();
        const result =
          await collection.deleteOne({_id: ObjectId(categoryId)});
        if (result.deletedCount === 0) {
          send(res, 404, `no category with id ${categoryId} found`);
        } else {
          res.end();
        }
      } catch (e) {
        console.error(
          'categories/[categoryId]/index.json.js del:',
          e
        );
        send(res, 500, {error: e});
      }
    }
     
    export async function put(req, res) {         #3
      const {categoryId} = req.params;
      const replacement = req.body;
     
      delete replacement._id;                     #4
     
      try {
        const collection = await getCollection();
        const result = await collection.replaceOne(
          {_id: ObjectId(categoryId)},
          replacement
        );
        const [obj] = result.ops;
        obj._id = categoryId;                     #5
        res.end(JSON.stringify(obj));
      } catch (e) {
        console.error(
          'categories/[categoryId]/index.json.js put:',
          e
        );
        send(res, 500, {error: e});
      }
    }