Giter Club home page Giter Club logo

nuxt-neo's People

Contributors

ezypeeze avatar github-actions[bot] avatar nperez0111 avatar rchl avatar renovate[bot] avatar tomlewis0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nuxt-neo's Issues

bodyparser middleware missing

Hi! I was trying out your module, but the createAction wasn't working, body was undefined.
So I installed express-bodyparser and added it to the middleware list, now it works.
Am I missing something or we should take care of our own parsers?

Automatically generate type hints from controllers

I've recently came across https://github.com/phero-hq/phero through https://blog.logrocket.com/phero-build-type-safe-full-stack-apps-with-typescript/ which is a project similar to nuxt-neo that solves some issues that nuxt-neo has. Namely:

  • it can auto-generate type information from "controllers" that are written in typescript. It then also generates a "client" (similar to nuxt-neo) that can use those type information.
  • it properly handles errors thrown on the server side so that even on the client side one can use instanceof to check type of the error. In nuxt-neo the behavior can be different whether call was made on the server or the client side and one type of error can mutate into a different type of error on the client unless there is some manual middleware code to handle that.

With that said, it's not really a replacement for nuxt-neo (yet) as it doesn't integrate with express (it starts its own backend server instead) and it doesn't have the feature that allows to perform pure function calls from the server-side -- it always makes a HTTP request. It also always makes a POST request instead of allowing to specify type of the HTTP method to use (which is not necessarily an issue unless maybe if someone expects caching in some cases).

This is just FYI. In theory we could adopt the logic to auto-generate types from TS code, like phero does but I don't think that we have resources for that. So instead maybe we can wait for phero to develop and then just provide a thin wrapper module for Nuxt for it (possibly as a separate package).

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm codecov Unavailable
npm eslint-loader Unavailable
npm eslint-plugin-node Available
npm eslint-plugin-standard Unavailable
npm querystring Unavailable
npm standard-version Available

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): replace devdependency standard-version with commit-and-tag-version ^9.5.0
  • chore(deps): update dependency path-to-regexp to v8
  • chore(deps): update devdependency c8 to v10
  • chore(deps): update devdependency eslint to v9
  • chore(deps): update devdependency eslint-config-prettier to v9
  • chore(deps): update devdependency eslint-plugin-ava to v15
  • chore(deps): update devdependency eslint-plugin-promise to v7
  • chore(deps): update devdependency eslint-plugin-standard to v5
  • chore(deps): update devdependency jsdom to v25
  • chore(deps): update devdependency nuxt to v3
  • chore(deps): update devdependency prettier to v3
  • chore(deps): update google-github-actions/release-please-action action to v4
  • chore(deps): update typescript-eslint monorepo to v8 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yaml
  • actions/checkout v3
  • actions/setup-node v3
.github/workflows/release-please.yml
  • google-github-actions/release-please-action v3
  • actions/checkout v3
  • actions/setup-node v3
npm
docs/package.json
  • vuepress ^1.9.7
package.json
  • body-parser ^1.20.1
  • express ^4.18.2
  • path-to-regexp ^6.2.1
  • @nuxt/types ^2.15.8
  • @typescript-eslint/eslint-plugin ^5.43.0
  • @typescript-eslint/parser ^5.43.0
  • ava ^3.15.0
  • axios ^0.27.1
  • browserslist ^4.21.4
  • c8 ^7.12.0
  • codecov ^3.8.2
  • core-js ^3.26.1
  • eslint ^8.28.0
  • eslint-config-prettier ^8.5.0
  • eslint-config-standard ^16.0.3
  • eslint-loader ^4.0.2
  • eslint-plugin-ava ^13.2.0
  • eslint-plugin-import ^2.26.0
  • eslint-plugin-node ^11.1.0
  • eslint-plugin-promise ^6.1.1
  • eslint-plugin-standard ^4.1.0
  • eslint-plugin-vue ^8.7.1
  • esm ^3.2.25
  • jsdom ^19.0.0
  • lodash ^4.17.21
  • nuxt ^2.15.8
  • pre-commit ^1.2.2
  • prettier ^2.7.1
  • querystring ^0.2.1
  • standard-version ^9.3.2
  • sure ^0.0.3
  • typescript ^4.9.3

  • Check this box to trigger a request for Renovate to run again on this repository

Context in controller class

is it possible to have the Nuxt Context in the controller classes? (or whatever to be able to pass parameters to the controller class) (I need to retrieve the sequelize instance)
Thank you

Param encoding handling differences between server & client side

With an endpoint like:

        getAction: {
            path: '/:foo',
            verb: 'GET'
        },

The foo might include a /, or some other (for example?), character that would break the API call when made on the client-side but it would work just fine when made on the server-side.

For it to work the user would have to encode it first (with encodeURI or encodeURIComponent) but that would then break the server-side API call because there would be nothing to decode the param in the handler.

I think that it can be fixed by just encoding the parameters in the module before making the client-side API call but I don't know if there is really a proper way of encoding that would work in all cases. Depending on the use case It's possible to encode "too much". For my apps encodeURIComponent would be a correct way to encode params but others might need more relaxed encodeURI or maybe even something custom so this should likely be customizable.

Incorrect path handling when params not provided

  • When you have a route with a /:foo path and you don't pass the the foo param when making a request then a request with a literal /:foo path will be made. This seems non-ideal. The param is required so the error should probably be more explicit and triggered before the request is made?
  • The module doesn't seem to declare support for optional params (/:foo?) but I think it should be able to support those. This kinda ties to the previous issue.

Add Typescript compatibility

The project doesn't currently support Typescript since it is unable to map file names to routes. A pretty simple change has solved this issue for me and could be useful for others still using this package.

diff --git a/node_modules/nuxt-neo/lib/server_middleware/api.js b/node_modules/nuxt-neo/lib/server_middleware/api.js
index 8928d11..a78150d 100755
--- a/node_modules/nuxt-neo/lib/server_middleware/api.js
+++ b/node_modules/nuxt-neo/lib/server_middleware/api.js
@@ -104,7 +104,7 @@ function injectBodyParsers(options) {
 async function injectControllers(router, options) {
     for (const path of getControllerFiles(options.directory)) {
         const relativePath = path.replace(options.directory, '');
-        const routePrefix = relativePath.replace(/\/index|\.js/g, '').split('/').map(camelcaseToDashcase).join('/');
+        const routePrefix = relativePath.replace(/\/index|\.(js|ts)/g, '').split('/').map(camelcaseToDashcase).join('/');
 
         router.use(routePrefix, await createControllerRouter(path, options));
     };
diff --git a/node_modules/nuxt-neo/lib/utility/controllers.js b/node_modules/nuxt-neo/lib/utility/controllers.js
index bd5d5ee..be76113 100755
--- a/node_modules/nuxt-neo/lib/utility/controllers.js
+++ b/node_modules/nuxt-neo/lib/utility/controllers.js
@@ -138,7 +138,7 @@ async function controllerMappingRecursive(mapping, parts, onEmpty) {
 async function controllerMapping(directory, controllerValue) {
     const mapping = {};
     for (const path of getControllerFiles(directory)) {
-        const relativePath = path.replace(directory, '').replace(/\/index|\.js/g, '');
+        const relativePath = path.replace(directory, '').replace(/\/index|\.(js|ts)/g, '');
         const routePrefix = relativePath.split('/').map(camelcaseToDashcase).join('/');
 
         await controllerMappingRecursive(mapping, relativePath.substring(1).split('/'), async function () {

This issue body was partially generated by patch-package.

Promise.catch() in plugins.api.template.js

/**
 * Runs possible error handler
 *
 * @param error
 * @returns {Function}
 */
function runErrorHandler(error) {
    return ErrorHandler && ErrorHandler(error) || Promise.catch(error);
}

Promise.prototype.catch() exists. Promise.catch() does not. Maybe this is supposed to be Promise.reject(error)?

Modifying a controller doesn't reload it

After controlled is modified, Nuxt (soft) restarts but the runtime code is not updated so Nuxt has to be restarted manually to see the changes.

I thought that #15 will fix it but it doesn't.

I guess the root issue is that async imports are used and that messes up the dependency graph for "jiti".

Not sure if it's fixable but logging anyway.

ES syntax not supported in api controllers

The javascript files within the api directory currently only work when in CommonJS syntax. This is a bit annoying because with the recent Nuxt versions (ones that use jiti) it's possible to use the ES syntax pretty much everywhere else (including server middleware).

Nuxt 2.15.8

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.