Code Monkey home page Code Monkey logo

Comments (9)

HyperBrain avatar HyperBrain commented on June 17, 2024

For the current version of the models plugin and Serverless this approach should work for your special use case although it is not universal as you can define your models as s-models.json or s-models.yaml.

In future this could even be part of the plugin itself, so that it could generate a validator function/class or provide a way to retrieve the model definitions at runtime. But as I need to do excessive changes for the upcoming Serverless V1, this will not happen in this version.
I will try to keep the model file location the same for Serverless V1 but as things are not yet finalized there, it might still change.

from serverless-models-plugin.

ismarslomic avatar ismarslomic commented on June 17, 2024

In my case I use only json, so it is quite easy to load the models.

In regards providing validate function as part of the plugin. That depends of what scope this plugin will have in future. So far it is isolated for deploying models to API Gateway, which it does greatly. Doing validations as well would extend its current scope.

Off topic: when is serverless v1 release planned?

from serverless-models-plugin.

HyperBrain avatar HyperBrain commented on June 17, 2024

Exactly.
They are already working on the new version, but I do not know any date when it will be released,

from serverless-models-plugin.

ismarslomic avatar ismarslomic commented on June 17, 2024

New obstacle, s-models.json is placed in the root of my project, but Im putting all function code within /function folder, which is also the one being deployed to AWS. This means that I do not have access to s-models.json in function handler when deployed to AWS since it is not bundled within the .zip file. I know I can modify handler path in s-function.json to include all files in the project, but that will increase the total file size.

Is it possible to retrieve models in other way, within the function handler?

from serverless-models-plugin.

HyperBrain avatar HyperBrain commented on June 17, 2024

Currently not. As a hack you might symlink the s-models.json into your function root.

from serverless-models-plugin.

ismarslomic avatar ismarslomic commented on June 17, 2024

Could you please be more specific?

from serverless-models-plugin.

HyperBrain avatar HyperBrain commented on June 17, 2024

Like this

+ s-project.json
+ s-models.json
+ function
   + node_modules
   + s-models.json (symlink to ../s-models.json)

from serverless-models-plugin.

ismarslomic avatar ismarslomic commented on June 17, 2024

Aah. Thanks. But really an hack, specially when commiting to GIT.

from serverless-models-plugin.

HyperBrain avatar HyperBrain commented on June 17, 2024

Yes it is :-) But at least GIT handles symlinks correctly.

from serverless-models-plugin.

Related Issues (11)

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.