profile
viewpoint

raynalf/adrar_battleship 2

Jeu de bataille navale en collaboration

Waxoussou/btn-hvr 0

boutons animés

Waxoussou/contactForm1 0

exemple de contact form html/css

Waxoussou/ContactFormNode 0

simple ContactForm with node.js/mongoDb

Waxoussou/Deno_Chat_App 0

simple chat app with Deno and Preact

Waxoussou/GlitchOfDeno 0

first time testing deno

Waxoussou/learnGit 0

apprendre a gerer serveur distant

create barnchWaxoussou/Deno_Chat_App

branch : master

created branch time in 11 days

created repositoryWaxoussou/Deno_Chat_App

simple chat app with Deno and Preact

created time in 11 days

create barnchWaxoussou/React-sideNavMenu

branch : master

created branch time in a month

created repositoryWaxoussou/React-sideNavMenu

created time in a month

issue commentmanyuanrong/deno_mongo

Cannot make projection ?

thanks @radek3911 . I 've got all the answers so far. Issue is closed

Waxoussou

comment created time in a month

issue closedmanyuanrong/deno_mongo

Cannot make projection ?

First, i'd like to thank you for the amazing job you've been doing.

I was playing with Deno and Mongo and I just realized that it was impossible for me to make projection when returning data from a find query. const productList = await products.find({ }, {name: 1, price:1 , _id:0}) the result of my productList variable contains all products with their price and their id too ... Am I missing something or is it something that is just not working for the moment ?

closed time in a month

Waxoussou

issue commentmanyuanrong/deno_mongo

Cannot make projection ?

indeed, that does work as expected now with the $match parameter. It does work without it in Mongo cli for example, but not with the deno driver I believe... Thanks @radek3911 for that solution

Waxoussou

comment created time in a month

issue commentmanyuanrong/deno_mongo

Cannot make projection ?

with aggregate :

const getProducts = async ({ response }) => {
        const productList = await products.aggregate(
            { $group: { _id: "$name" } }
        )
        response.body = {
            success: true,
            data: productList,
        }}
Waxoussou

comment created time in a month

issue commentmanyuanrong/deno_mongo

Cannot make projection ?

here is some data sample :

{
    "_id": {
        "$oid": "5eca9b8d41b84920755766e4"
    },
    "name": "banana",
    "price": 12
},
{
    "_id": {
        "$oid": "5eca9b8d41b84920755766e5"
    },
    "name": "fraise",
    "price": 1.41
},
{
    "_id": {
        "$oid": "5ecab4ed0090019a00b58991"
    },
    "name": "bernard",
    "price": 2.23
}

nothing too.... complicated. And for the my code , a simple route : routes.js : router.get('/api/v1/products', getProducts)

products.js :

// @desc Get all products  
// @route GET/api/v1/products 
const getProducts = async ({ response }) => {
        const productList = await products.find({})
        response.body = {
            success: true,
            data: productList,
        }

}

Waxoussou

comment created time in a month

issue commentmanyuanrong/deno_mongo

Cannot make projection ?

Hi,

The function is aggregate() not aggregation(). I have made a PR #37 that fixes the typo in README.md.

Hi @radek3911 , thanks for that information. I did try with aggregate instead of aggregation (and have been triyng again since i red your message but unfortunately, that does not work either. Here is what I get from the console :

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Error("invalid type: map, expected a sequence", line: 1, column: 63)', src/command/aggregation.rs:19:37
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[denon] app crashed - waiting for file changes before starting ...
Waxoussou

comment created time in a month

issue commentmanyuanrong/deno_mongo

Cannot make projection ?

You can currently use aggregate

Thanks @manyuanrong I have tried to use aggregate , but still not working. (or something I do could be wrong ...) Here How I did my aggregation :

        const productList = await products.aggregation(
            { $group: { _id:  "$name" } }
        )

I tested first that it would work correctly on mongo (cli) and it does work as expected but on deno, I get that response :

TypeError: products.aggregation is not a function
    at getProducts (file:///Users/maxbook/Code/denoDiscovery/controllers/products.js:15:44)
    at dispatch (https://deno.land/x/oak/middleware.ts:35:32)
    at https://deno.land/x/oak/router.ts:416:18
    at dispatch (https://deno.land/x/oak/middleware.ts:35:32)
    at composedMiddleware (https://deno.land/x/oak/middleware.ts:41:12)
    at dispatch (https://deno.land/x/oak/router.ts:420:28)
    at dispatch (https://deno.land/x/oak/middleware.ts:35:32)
    at default (file:///Users/maxbook/Code/denoDiscovery/middlewares/errorHandler.js:4:15)
    at dispatch (https://deno.land/x/oak/middleware.ts:35:32)
    at Object.composedMiddleware [as middleware] (https://deno.land/x/oak/middleware.ts:41:12)
Waxoussou

comment created time in a month

create barnchWaxoussou/vanillaJs_OOP

branch : master

created branch time in a month

created repositoryWaxoussou/vanillaJs_OOP

Very simple toDo app using localStorage and javascript classes

created time in a month

push eventWaxoussou/GlitchOfDeno

Waxoussou

commit sha 69ccd2265f24d6256ccf6ab192b321593e3815e7

Update README.md

view details

push time in 2 months

push eventWaxoussou/GlitchOfDeno

Waxoussou

commit sha cd6691160fa91cb3a01444d82d8ef5cc0ae9a9da

update readme

view details

push time in 2 months

push eventWaxoussou/GlitchOfDeno

Waxoussou

commit sha d29d003459b251a179bfbddfbfc704485397bff4

second commit

view details

push time in 2 months

issue openedmanyuanrong/deno_mongo

Cannot make projection ?

First, i'd like to thank you for the amazing job you've been doing.

I was playing with Deno and Mongo and I just realized that it was impossible for me to make projection when returning data from a find query. const productList = await products.find({ }, {name: 1, price:1 , _id:0}) the result of my productList variable contains all products with their price and their id too ... Am I missing something or is it something that is just not working for the moment ?

created time in 2 months

issue closedoakserver/oak

Cannot get params from context

It seems that get method does not handle the parameter from the url if I write that route router.get('/book/:id', (context) => { // route action }) nothing is happening. I removed the '/:id' part of the string and that seems to be the issue here ... but how to indicate parameters if not that way ?

closed time in 2 months

Waxoussou

issue commentoakserver/oak

Cannot get params from context

Hi @Waxoussou 😄

Your error handler middleware should be placed after declaring the routes. The error will happen in one of the routes and then it will be passed to the handler.

Also, I tested your routes and they seem to be working correctly.

I think that you passing a query param instead of a route param

I've tried to send request with curl : ~ curl -X GET http://localhost:5050/api/v1/products/?id=1

Instead of /products/?id=1 it should be /products/1

thanks so much @LauraBeatris !!! indeed , I was passing query params instead ! damn' ... Btw, would you know how to handle query param with oak though ?

About my error handler, it was working well even declared before the routes ... I did get errors each time i got one... How can it be ?

Waxoussou

comment created time in 2 months

issue commentoakserver/oak

Get Form Values from body.

If the type is form, It will work on x-www-form-urlencoded, but for formdara, it doesnt work. I find one function in deno's std/mime/multipart.ts that could work with using MultipartReader class. But I got another error. I created a new issue for deno; denoland/deno#5830

x-www-form-urlencoded is not working for me ... that my point ... whereas formdata is working for me ... :/

aha? urlencoded could parse to UrlSearchParams, but formdata has boundary and other symbol, it should not work on formdata. X_X.

i know should not ... but here what i get with urlencoded : Capture d’écran 2020-05-25 à 12 20 33

and with form-data : Capture d’écran 2020-05-25 à 12 20 52

(using Postman)

devYusuf

comment created time in 2 months

issue commentoakserver/oak

Get Form Values from body.

If the type is form, It will work on x-www-form-urlencoded, but for formdara, it doesnt work. I find one function in deno's std/mime/multipart.ts that could work with using MultipartReader class. But I got another error. I created a new issue for deno; https://github.com/denoland/deno/issues/5830

x-www-form-urlencoded is not working for me ... that my point ... whereas formdata is working for me ... :/

devYusuf

comment created time in 2 months

issue commentoakserver/oak

Get Form Values from body.

@devYusuf you need to supply what sort of request you are making and ctx.request.body() returns an Promise<Body> and you are not awaiting the promise or otherwise handling the promise.

    const body = {type: '', value: {}};
    if (ctx.request.hasBody) {
      const result = await ctx.request.body({
        contentTypes: {
          json: ['application/json'],
          form: ['multipart', 'urlencoded'],
          text: ['text']
        }
      });
      const {type, value} = result;
      if (type === 'form') {
        body.type = type;
        for (let [key, item] of value) {
          body.value[key] = item;
        }
      } else {
        Object.assign(body, result);
      }
    }
    ctx.body = body;
    await next();

I think it will work again. I checked the code about send function.

image all the form type returns URLSearchParams instance. I upload my code here. You can check it. deno-demo.zip

i've tried to specified the request but still does not seem to work :


const addProduct = async ({ request, response, params }) => {
    if (!request.hasBody) {
        response.status = 400;
        response.body = {
            success: false,
            msg: 'no data'
        }
    } else {
        const body = await request.body({
            contentTypes: {
                json: ['application/json'],
                form: [ 'multipart', 'urlencoded'],
                text: ['text']
            }
        });
        const { name, price } = body.value;
        console.log(body, name, price)

devYusuf

comment created time in 2 months

issue commentoakserver/oak

Cannot get params from context

Thanks for the answers. Here, a bit more of my code :

app.js : `import { Application } from './deps.js'; import errorHandler from './middlewares/errorHandler.js' import router from './routes.js';

const port = 5050; const app = new Application()

app.use(errorHandler) app.use(router.routes()) app.use(router.allowedMethods())

console.log(server running on ${port});

await app.listen({ port }) my router (route.js) :import { Router } from './deps.js'; import { getProducts, getProduct, addProduct, updateProduct, deleteProduct } from './controllers/products.js'

const router = new Router();

router.get('/api/v1/products', getProducts) .get('/api/v1/products/:id', getProduct) .post('/api/v1/products', addProduct) .put('/api/v1/products/:id', updateProduct) .delete('/api/v1/products/:id', deleteProduct)

.get("/book/:id", (context) => {
    console.log(context.params, context.params.id)
});

export default router;`

I've been creating my route book/:id just to test since i was not finding any params on my others routes

And finally, the products.js file which contains all the routes method related to each point :

` import { MongoClient } from '../deps.js'

const client = new MongoClient(); client.connectWithUri("mongodb://localhost:27017");

const db = client.database("denoTesting"); const products = db.collection("products");

// @desc Get all products
// @route GET/api/v1/products const getProducts = async ({ response }) => { const productList = await products.find({}) response.body = { success: true, data: productList, } }

// @desc Get a product
// @route GET/api/v1/products/:id const getProduct = ({ params, response }) => { console.log('HELLO DENO', params)

}`

I've tried to send request with curl : ~ curl -X GET http://localhost:5050/api/v1/products/?id=1 or even with Postman Let me know if you need anything else. Thanks for your time ;)

Waxoussou

comment created time in 2 months

create barnchWaxoussou/GlitchOfDeno

branch : master

created branch time in 2 months

created repositoryWaxoussou/GlitchOfDeno

first time testing deno

created time in 2 months

issue openedoakserver/oak

Cannot get params from context

It seems that get method does not handle the parameter from the url if I write that route router.get('/book/:id', (context) => { // route action }) nothing is happening. I removed the '/:id' part of the string and that seems to be the issue here ... but how to indicate parameters if not that way ?

created time in 2 months

issue commentoakserver/oak

Get Form Values from body.

Same issue here

devYusuf

comment created time in 2 months

issue commentbradtraversy/mern_shopping_list

Successful Heroku Deployment but Application not rendered - ES6 Issue

Guess I have a similar issue. API working good but no rendre of m'y react front ... Not any news on solving that issue ?

srlars

comment created time in 3 months

more