getContextModel

const getContextModel = () => context;

Example
    
      const addCityValidator = () => {
        return object({
          set: object({
            ...locationPure,
            isCapital: optional(boolean()),
            country: objectIdValidation,
            }),
            get: coreApp.schemas.selectStruct("city", 1),
        });
      };
      const addCity: ActFn = async (body) => {
        const { country, isCapital, name, population, abb } = body.details.set;
      

const myContext = coreApp.contextFns.getContextModel();

return await cities.insertOne({ doc: { name, population, abb }, projection: body.details.get, relations: { country: { _ids: new ObjectId(country), relatedRelations: { citiesAsc: true, citiesDesc: true, citiesByPopAsc: true, citiesByPopDesc: true, capitalCity: isCapital, }, }, }, }); };

const addSomthingToContext = () => { const prevContext = coreApp.contextFns.getContextModel(); coreApp.contextFns.addContext({ ...prevContext, userName: "Mina" }); }

coreApp.acts.setAct({ schema: "city", actName: "addCity", validator: addCityValidator(), fn: addCity, })

preAct: [addSomthingToContext]

Return Of Example
    
      myContext: {
        Headers: Headers {
          accept: "*/*",
          "accept-encoding": "gzip, deflate, br",
          "accept-language": "en-US,en;q=0.9",
          authorization: "",
          connection: "keep-alive",
          "content-length": "349",
          "content-type": "application/json",
          host: "localhost:1366",
          origin: "http://localhost:1366",
          referer: "http://localhost:1366/playground",
          "sec-ch-ua": '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
          "sec-ch-ua-mobile": "?0",
          "sec-ch-ua-platform": '"Linux"',
          "sec-fetch-dest": "empty",
          "sec-fetch-mode": "cors",
          "sec-fetch-site": "same-origin",
          "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.3"... 1 more character
        },
        body: {
          service: "main",
          model: "city",
          act: "addCity",
          details: {
            get: {
              _id: 1,
              name: 1,
              population: 1,
              abb: 1,
              country: [Object],
              users: [Object],
              lovedByUser: [Object]
            },
            set: {
              name: "hamedan",
              population: 500000,
              abb: "hmd",
              isCapital: false,
              country: "6598f6594dd08ab9b8598206"
            }
          }
        },
        con: {
          Headers: Headers {
            accept: "*/*",
            "accept-encoding": "gzip, deflate, br",
            "accept-language": "en-US,en;q=0.9",
            authorization: "",
            connection: "keep-alive",
            "content-length": "349",
            "content-type": "application/json",
            host: "localhost:1366",
            origin: "http://localhost:1366",
            referer: "http://localhost:1366/playground",
            "sec-ch-ua": '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": '"Linux"',
            "sec-fetch-dest": "empty",
            "sec-fetch-mode": "cors",
            "sec-fetch-site": "same-origin",
            "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.3"... 1 more character
          },
          body: {
            service: "main",
            model: "city",
            act: "addCity",
            details: { get: [Object], set: [Object] }
          },
     

userName: "Mina"

} }