Comments (6)
@c0ncentus : I did use that link to set it up :
https://dashboard.useoptic.com/setup/express-js
The main change is
app.listen(process.env.OPTIC_API_PORT || process.env.PORT)
in your case :
app.listen(process.env.OPTIC_API_PORT || 3000)
I see you have
app.listen(3000, () => { console.log('My API is running...'); });
in your code example.
Hope it helps.
from optic.
I will see later if I have another trouble ^^
depend on effort / simple of reproduce and what happened.
from optic.
Hi @c0ncentus - The api init
command doesn't start your server so I suspect it's something else, but you will eventually need to make the changes above (thanks @lvenier!).
It looks like you are running on Windows, which we have not tested rigorously. I am planning to get a Windows setup for testing soon, but in the meantime, if you continue to run into issues could you record a screencast so we can see all the steps and complete error messages?
from optic.
import * as express from 'express';
// tslint:disable-next-line: no-duplicate-imports
const app = express();
app.get('/', (req: any, res: any) => { res.json({ test: 'Api is alive !' }); });
app.get('/Test', (req: any, res: any) => { res.json({ exTest: 'Expected this !' }); });
app.listen(process.env.OPTIC_API_PORT || 3000, () => { console.log('My API is running...'); });
export default app;
still the same issue
there it is : https://github.com/c0ncentus/test_Optic (the repo)
from optic.
@c0ncentus thanks for the additional info!
When you run api init
Optic doesn't know about your code yet. api init
is the command that asks you questions so that it can learn how to run your code when you run the api start
command. If you are having issues running api init
, then it is most likely an installation issue.
Based on the original error message you shared:
Error: Module did not self-register at Object.<anonymous> (C:/Users/Martin/AppData/Roaming/npm/node_modules/@useoptic/cli/node_modules/registry-js/dist/lib/registry.js:4:7)
it seems like the failure is that one of our dependencies is not working. The most likely cause is upgrading your node version without rebuilding Optic.
Can you npm uninstall and reinstall @useoptic/cli
and let me know if you still run into the issue? I can not replicate your issue on the latest node 13 on Mac, so it would help to see exactly what you are seeing in the terminal when you install and run api init
.
from optic.
npm uninstall -g @useoptic/cli
npm install -g @useoptic/cli
[ .................] - fetchMetadata: sill resolveWithNewModule [email protected] checking installable status[ .................] | fetchMetadata: sill resolveWithNewModule
[ .................] \ fetchMetadata: sill resolveWithNewModule
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
C:\Users\Martin\AppData\Roaming\npm\api -> C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\bin\run
> [email protected] install C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\registry-js
> prebuild-install || node-gyp rebuild
prebuild-install WARN install No prebuilt binaries found (target=13.6.0 runtime=node arch=x64 libc= platform=win32)
C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\registry-js>if not defined npm_config_node_gyp (node "C:\Users\Martin\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Users\Martin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Les projets sont générés individuellement dans cette solution. Pour activer la génération en parallèle, ajoutez le commutateur "/m".
main.cc
win_delay_load_hook.cc
CrÚation de la bibliothÞque C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\registry-js\build\Relea
se\registry.lib et de l'objet C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\registry-js\build\Releas
e\registry.exp
registry.vcxproj -> C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\registry-js\build\Release\\registr
y.node
> [email protected] install C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\win-version-info
> node skip.js || prebuild-install || node-gyp rebuild
prebuild-install WARN install No prebuilt binaries found (target=13.6.0 runtime=node arch=x64 libc= platform=win32)
C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\win-version-info>if not defined npm_config_node_gyp (node "C:\Users\Martin\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Users\Martin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Les projets sont générés individuellement dans cette solution. Pour activer la génération en parallèle, ajoutez le commutateur "/m".
VersionInfo.cc
showver.cc
win_delay_load_hook.cc
CrÚation de la bibliothÞque C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\win-version-info\build\
Release\VersionInfo.lib et de l'objet C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\win-version-info
\build\Release\VersionInfo.exp
VersionInfo.vcxproj -> C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\win-version-info\build\Release\
\VersionInfo.node
> [email protected] postinstall C:\Users\Martin\AppData\Roaming\npm\node_modules\@useoptic\cli\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
[lot of things ....]
thats weird but it work :)
However i change many times the node version before the install of optic cli : o
thanks for help 👍
from optic.
Related Issues (20)
- If any of the urls in the openapi spec match the url that is defined in optic.yml, optic breaks HOT 2
- Optic throws an error when receiving multipart/form-data requests HOT 2
- Optic validates exclusiveMinimum + exclusiveMaximum w 3.1.0 schema regardless of version
- Backstage renovate bot failing upgrade to 0.53 HOT 8
- Extend documentation quality ruleset to check for dead links.
- Replace deprecated analytics-node in @useoptic/optic HOT 2
- Docs: The command in generate a changelog is wrong HOT 2
- Examples package causes AJV errors
- Include operations exclusion for spectral ruleset HOT 1
- An ajv error is falsely reported when validating examples HOT 1
- `optic capture` failing due to discriminated union represented as `oneOf` with enums HOT 5
- Cannot use diff-all offline HOT 1
- Failed writing patches to openapi.yml HOT 8
- `optic run` fails to report exit code when the diff fails HOT 1
- `optic lint` gets confused when I set `OPTIC_TOKEN` instead of the default config HOT 1
- Could not handle drive letter with lower case on Windows HOT 1
- Bump package `latest-version` to latest version to resolve SNYK-JS-GOT-2932019 HOT 1
- Optic is failing to parse API spec that has Anchor/Aliases HOT 5
- warning: invalid allOf variant warning if allOf includes oneOf HOT 5
- Compatibility check: [error] request property oneOf schema did not overlap with the previous schema.
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 optic.