Comments (9)
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.
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.
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.
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.
Currently not. As a hack you might symlink the s-models.json into your function root.
from serverless-models-plugin.
Could you please be more specific?
from serverless-models-plugin.
Like this
+ s-project.json
+ s-models.json
+ function
+ node_modules
+ s-models.json (symlink to ../s-models.json)
from serverless-models-plugin.
Aah. Thanks. But really an hack, specially when commiting to GIT.
from serverless-models-plugin.
Yes it is :-) But at least GIT handles symlinks correctly.
from serverless-models-plugin.
Related Issues (11)
- JSON example HOT 2
- Serverless v1.0 incompatibility HOT 10
- Possible bug / when sls dash deploy in function folder models are not found HOT 2
- updating s-project.json HOT 1
- 'sls models show' not working HOT 4
- Questions about Swagger compatibility and implications. HOT 6
- Error 'Model not defined: Empty' HOT 5
- Automatically add dependency to package.json HOT 1
- model removed from s-models.json is not delete in API Gateway HOT 3
- support multiple s-models.json|yaml files within anywhere of the project's space HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-models-plugin.